This guide will help set up your django project to use ReactJS
- django-webpack-loader==0.4.1 ( Connects Django project with Webpack)
| """Google spreadsheet related. | |
| Packages required: oauth2client, google-api-python-client | |
| * https://gist.github.com/miohtama/f988a5a83a301dd27469 | |
| """ | |
| from oauth2client.service_account import ServiceAccountCredentials | |
| from apiclient import discovery | |
| def get_credentials(scopes: list) -> ServiceAccountCredentials: |
Hopefully this will answer "How do I setup or start a Django project?" I was trying to set up my own website, and there was a lot to read, learn and digest! Therefore, I put this together which is a collection of all the guides/blog posts/articles that I found the most useful. At the end of this, you will have your barebones Django app configured and ready to start building :)
NOTE: This guide was built using Django 1.9.5, NodeJS 4+ with NPM 3+
| import { Component } from "React"; | |
| export var Enhance = ComposedComponent => class extends Component { | |
| constructor() { | |
| this.state = { data: null }; | |
| } | |
| componentDidMount() { | |
| this.setState({ data: 'Hello' }); | |
| } | |
| render() { |
| from django.db import connection, models | |
| class MyManager(Manager): | |
| def raw_as_qs(self, raw_query, params=()): | |
| """Execute a raw query and return a QuerySet. The first column in the | |
| result set must be the id field for the model. | |
| :type raw_query: str | unicode | |
| :type params: tuple[T] | dict[str | unicode, T] | |
| :rtype: django.db.models.query.QuerySet | |
| """ |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |