├── server
├── __init__.py
├── settings
│ ├── test.py
│ ├── __init__.py
│ ├── staging_base.py
│ ├── production_base.py
│ ├── development.py
│ ├── development_docker.py
│ └── common.py
├── apps
│ └── core
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── tests.py
│ │ ├── models.py
│ │ ├── apps.py
│ │ ├── templates
│ │ └── core
│ │ │ └── index.html
│ │ └── views.py
├── misc
│ └── requirements.txt
├── Dockerfile
├── manage.py
├── urls.py
└── wsgi.py
├── client
├── drf.png
├── redux.png
├── docker.png
├── reactjs.png
├── webpack.png
├── .babelrc
├── assets
│ └── js
│ │ ├── redux.png
│ │ ├── app.jsx
│ │ └── index.jsx
├── Dockerfile
├── index.html
├── src
│ ├── actions
│ │ └── actions.js
│ ├── reducers
│ │ ├── index.js
│ │ └── reducerDemo.js
│ ├── app.js
│ └── components
│ │ └── app.js
├── test
│ ├── components
│ │ └── app_test.js
│ └── test_helper.js
├── style
│ └── style.css
├── webpack.stats.json
├── README.md
├── server.js
├── package.json
└── webpack.config.js
├── docker-compose.yml
└── .gitignore
/server/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/settings/test.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/apps/core/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/apps/core/admin.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/apps/core/tests.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/settings/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/settings/staging_base.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/apps/core/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
--------------------------------------------------------------------------------
/client/drf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/drf.png
--------------------------------------------------------------------------------
/client/redux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/redux.png
--------------------------------------------------------------------------------
/client/docker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/docker.png
--------------------------------------------------------------------------------
/client/reactjs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/reactjs.png
--------------------------------------------------------------------------------
/client/webpack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/webpack.png
--------------------------------------------------------------------------------
/client/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["react", "es2015"],
3 | "plugins": ["react-hot-loader/babel"]
4 | }
5 |
--------------------------------------------------------------------------------
/client/assets/js/redux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/denvaar/drf-react-boilerplate/HEAD/client/assets/js/redux.png
--------------------------------------------------------------------------------
/server/apps/core/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class CoreConfig(AppConfig):
5 | name = 'core'
6 |
7 |
--------------------------------------------------------------------------------
/server/misc/requirements.txt:
--------------------------------------------------------------------------------
1 | Django==1.10.1
2 | djangorestframework==3.3.3
3 | psycopg2==2.6.1
4 | django-js-reverse==0.7.2
5 | django-webpack-loader==0.3.2
6 |
--------------------------------------------------------------------------------
/server/settings/production_base.py:
--------------------------------------------------------------------------------
1 | from settings.common import *
2 |
3 | DB_ENGINE = 'django.db.backends.mysql'
4 | STATIC_ROOT = '/opt/project/static/'
5 |
6 |
--------------------------------------------------------------------------------
/client/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:6.3
2 |
3 | WORKDIR /project/client
4 |
5 | COPY package.json /project/client
6 | RUN npm install
7 |
8 | COPY . /project/client
9 |
10 | EXPOSE 3000
11 |
--------------------------------------------------------------------------------
/server/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.5
2 | ENV PYTHONUNBUFFERED 1
3 | ENV PROJECT_ENV development_docker
4 | RUN mkdir /code
5 | WORKDIR /code
6 | ADD . /code/
7 | RUN pip install -r misc/requirements.txt
8 |
--------------------------------------------------------------------------------
/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/client/src/actions/actions.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 |
3 | export const DEMO = 'DEMO';
4 | let nextId = 0;
5 |
6 | export const demoAction = (text) => {
7 | return {
8 | type: DEMO,
9 | text: text,
10 | id: nextId++
11 | };
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/client/src/reducers/index.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 |
3 | import DemoReducer from './reducerDemo';
4 |
5 | const rootReducer = combineReducers({
6 | state: (state = {}) => state,
7 | demo: DemoReducer
8 | });
9 |
10 | export default rootReducer;
11 |
--------------------------------------------------------------------------------
/server/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
7 |
8 | from django.core.management import execute_from_command_line
9 |
10 | execute_from_command_line(sys.argv)
11 |
--------------------------------------------------------------------------------
/server/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import include, url
2 | from django.contrib import admin
3 | from django.views.generic import TemplateView
4 |
5 | from apps.core.views import Index
6 |
7 |
8 | urlpatterns = [
9 | url(r'^admin/', include(admin.site.urls)),
10 | url(r'^$', Index.as_view(), name='index'),
11 | ]
12 |
13 |
--------------------------------------------------------------------------------
/client/src/reducers/reducerDemo.js:
--------------------------------------------------------------------------------
1 | import { DEMO } from '../actions/actions.js';
2 |
3 | const demoReducer = (state = [], action) => {
4 | switch (action.type) {
5 | case DEMO:
6 | return {
7 | id: action.id,
8 | text: action.text
9 | };
10 | default:
11 | return state;
12 | }
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/client/test/components/app_test.js:
--------------------------------------------------------------------------------
1 | import { renderComponent , expect } from '../test_helper';
2 | import App from '../../src/components/app';
3 |
4 | describe('App' , () => {
5 | let component;
6 |
7 | beforeEach(() => {
8 | component = renderComponent(App);
9 | });
10 |
11 | it('exists', () => {
12 | expect(component).to.exist;
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/server/settings/development.py:
--------------------------------------------------------------------------------
1 | from settings.common import *
2 |
3 | DEBUG = True
4 |
5 | DATABASES = {
6 | 'default': {
7 | 'ENGINE': 'django.db.backends.postgresql_psycopg2',
8 | 'NAME': '[ENTER DB NAME]',
9 | 'USER': '[ENTER DB USER]',
10 | 'PASSWORD': '[ENTER PASSWORD]',
11 | 'HOST': '',
12 | 'PORT': '',
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/server/settings/development_docker.py:
--------------------------------------------------------------------------------
1 | from settings.common import *
2 |
3 | DEBUG = True
4 |
5 | DATABASES = {
6 | 'default': {
7 | 'ENGINE': 'django.db.backends.postgresql_psycopg2',
8 | 'NAME': 'postgres',
9 | 'USER': 'postgres',
10 | 'HOST': 'db',
11 | 'PORT': 5432,
12 | }
13 | }
14 |
15 | STATIC_ROOT = '/code/docker_static/'
16 |
--------------------------------------------------------------------------------
/client/style/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: Helvetica Neue, sans-serif;
3 | color: #343d46;
4 | font-size: 12px;
5 | }
6 |
7 |
8 | .init {
9 | display: -webkit-flex;
10 | display: flex;
11 | -webkit-flex-direction: column;
12 | flex-direction: column;
13 | -webkit-align-items: center;
14 | align-items: center;
15 | -webkit-justify-content: center;
16 | justify-content: center;
17 | }
18 |
--------------------------------------------------------------------------------
/client/webpack.stats.json:
--------------------------------------------------------------------------------
1 | {"status":"done","chunks":{"main":[{"name":"main-c34b3277f3b31e328359.js","publicPath":"http://localhost:3000/assets/bundles/main-c34b3277f3b31e328359.js","path":"/project/client/assets/bundles/main-c34b3277f3b31e328359.js"},{"name":"style.css","publicPath":"http://localhost:3000/assets/bundles/style.css","path":"/project/client/assets/bundles/style.css"}]},"publicPath":"http://localhost:3000/assets/bundles/"}
--------------------------------------------------------------------------------
/server/wsgi.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | env = os.environ.get('PROJECT_ENV', None)
4 |
5 | if env:
6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE',
7 | 'settings.{}'.format(os.environ['PROJECT_ENV']))
8 | else:
9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE',
10 | 'settings.development')
11 |
12 | from django.core.wsgi import get_wsgi_application
13 | application = get_wsgi_application()
14 |
15 |
--------------------------------------------------------------------------------
/client/README.md:
--------------------------------------------------------------------------------
1 | # Redux Boilerplate
2 |
3 | A predictable state container for Javascript apps.
4 |
5 | Check out [Redux](http://redux.js.org/) in more detail on the official site.
6 |
7 | #### Up and running
8 |
9 | There are two methods for getting started with this repo.
10 |
11 | ```
12 | > git clone https://github.com/sammyteahan/redux-boilerplate.git
13 | > cd redux-boilerplate
14 | > npm install
15 | > npm start
16 | ```
--------------------------------------------------------------------------------
/server/apps/core/templates/core/index.html:
--------------------------------------------------------------------------------
1 | {% load render_bundle from webpack_loader %}
2 |
3 |
4 |
5 | Project
6 |
7 |
8 | Python {{ python_version }}
9 | Django {{ django_version }}
10 | Django REST Framework {{ drf_version }}
11 |
12 | {% render_bundle 'main' %}
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/client/server.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack')
2 | var WebpackDevServer = require('webpack-dev-server')
3 | var config = require('./webpack.config')
4 |
5 | new WebpackDevServer(webpack(config), {
6 | publicPath: config.output.publicPath,
7 | hot: true,
8 | inline: true,
9 | historyApiFallback: true
10 | }).listen(3000, '0.0.0.0', function (err, result) {
11 | if (err) {
12 | console.log(err)
13 | }
14 |
15 | console.log('Listening at 0.0.0.0:3000')
16 | })
17 |
18 |
--------------------------------------------------------------------------------
/client/src/app.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { Provider } from 'react-redux';
4 | import { createStore, applyMiddleware } from 'redux';
5 |
6 | import App from './components/app';
7 | import reducers from './reducers';
8 |
9 | const createStoreWithMiddleware = applyMiddleware()(createStore);
10 |
11 | ReactDOM.render(
12 |
13 |
14 |
15 | , document.querySelector('.container'));
16 |
--------------------------------------------------------------------------------
/client/assets/js/app.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Component } from 'react';
3 |
4 | export default class App extends Component {
5 | render() {
6 | return (
7 |
8 |
Rendered by React
9 | Rendered by React
10 |
11 | );
12 | }
13 | }
14 | /*
15 | const App = () => {
16 | return (
17 |
18 |
Hello from React
19 | Hello from React
20 | Hello from React
21 |
22 | );
23 | }
24 | export default App;
25 | */
26 |
--------------------------------------------------------------------------------
/server/apps/core/views.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | import django
4 | import rest_framework
5 | from django.views.generic import TemplateView
6 |
7 |
8 | class Index(TemplateView):
9 | template_name = 'core/index.html'
10 |
11 | def get_context_data(self, **kwargs):
12 | context = super(Index, self).get_context_data(**kwargs)
13 | context['django_version'] = '{}.{}.{}'.format(*django.VERSION)
14 | context['drf_version'] = rest_framework.VERSION
15 | context['python_version'] = sys.version
16 | return context
17 |
18 |
--------------------------------------------------------------------------------
/client/assets/js/index.jsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { Provider } from 'react-redux';
4 | import { createStore, applyMiddleware } from 'redux';
5 |
6 | import App from '../../src/components/app';
7 | import reducers from '../../src/reducers';
8 | import '../../style/style.css';
9 |
10 | const createStoreWithMiddleware = applyMiddleware()(createStore);
11 |
12 | ReactDOM.render(
13 |
14 |
15 |
16 | , document.getElementById('app'));
17 |
18 | module.hot.accept();
19 |
--------------------------------------------------------------------------------
/client/src/components/app.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Component } from 'react';
3 |
4 | import ReactImg from '../../reactjs.png';
5 | import ReduxImg from '../../redux.png';
6 | import WebpackImg from '../../webpack.png';
7 | import DRFImg from '../../drf.png';
8 | import DockerImg from '../../docker.png';
9 |
10 | export default class App extends Component {
11 |
12 | render() {
13 | return (
14 |
15 |

16 |

17 |

18 |

19 |

20 |
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | services:
4 | client:
5 | build: client
6 | working_dir: /project/client
7 | command: node server.js
8 | ports:
9 | - "3000:3000"
10 | volumes:
11 | - ./client:/project/client
12 | - /project/client/node_modules
13 | db:
14 | image: postgres
15 |
16 | server:
17 | build: server
18 | environment:
19 | - PROJECT_ENV=development_docker
20 | - PYTHONPATH=/code/server/
21 | - DJANGO_SETTINGS_MODULE=settings.development_docker
22 | command: python server/manage.py runserver 0.0.0.0:8000
23 | volumes:
24 | - .:/code
25 | ports:
26 | - "8000:8000"
27 | links:
28 | - db
29 | - client
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.pyc
3 | node_modules/
4 | dterm_stuff/
5 | .dockerbashrc
6 | server/celerybeat-schedule
7 | docker_static/
8 | # server/apps/core/static/core/bundles
9 |
10 | *.DS_Store
11 |
12 | # Byte-compiled / optimized / DLL files
13 | __pycache__/
14 | *.py[cod]
15 | *$py.class
16 |
17 | # C extensions
18 | *.so
19 |
20 | # Distribution / packaging
21 | .Python
22 | env/
23 | build/
24 | develop-eggs/
25 | dist/
26 | downloads/
27 | eggs/
28 | .eggs/
29 | lib/
30 | lib64/
31 | parts/
32 | sdist/
33 | var/
34 | *.egg-info/
35 | .installed.cfg
36 | *.egg
37 |
38 | # PyInstaller
39 | # Usually these files are written by a python script from a template
40 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
41 | *.manifest
42 | *.spec
43 |
44 | # Installer logs
45 | pip-log.txt
46 | pip-delete-this-directory.txt
47 |
48 | # Unit test / coverage reports
49 | htmlcov/
50 | .tox/
51 | .coverage
52 | .coverage.*
53 | .cache
54 | nosetests.xml
55 | coverage.xml
56 | *,cover
57 | .hypothesis/
58 |
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 |
64 |
65 |
--------------------------------------------------------------------------------
/client/test/test_helper.js:
--------------------------------------------------------------------------------
1 | import _$ from 'jquery';
2 | import React from 'react';
3 | import ReactDOM from 'react-dom';
4 | import TestUtils from 'react-addons-test-utils';
5 | import jsdom from 'jsdom';
6 | import chai, { expect } from 'chai';
7 | import chaiJquery from 'chai-jquery';
8 | import { Provider } from 'react-redux';
9 | import { createStore } from 'redux';
10 | import reducers from '../src/reducers';
11 |
12 | global.document = jsdom.jsdom('');
13 | global.window = global.document.defaultView;
14 | const $ = _$(window);
15 |
16 | chaiJquery(chai, chai.util, $);
17 |
18 | function renderComponent(ComponentClass, props = {}, state = {}) {
19 | const componentInstance = TestUtils.renderIntoDocument(
20 |
21 |
22 |
23 | );
24 |
25 | return $(ReactDOM.findDOMNode(componentInstance));
26 | }
27 |
28 | $.fn.simulate = function(eventName, value) {
29 | if (value) {
30 | this.val(value);
31 | }
32 | TestUtils.Simulate[eventName](this[0]);
33 | };
34 |
35 | export {renderComponent, expect};
36 |
--------------------------------------------------------------------------------
/client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "redux-boilerplate",
3 | "version": "1.0.0",
4 | "description": "Simple starting point for a Redux with React app",
5 | "main": "app.js",
6 | "repository": "",
7 | "scripts": {
8 | "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --host 0.0.0.0 --port 8080 --inline --hot",
9 | "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.js'",
10 | "test:watch": "npm run test -- --watch"
11 | },
12 | "author": "",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "babel-core": "^6.2.1",
16 | "babel-loader": "^6.2.0",
17 | "babel-preset-es2015": "^6.1.18",
18 | "babel-preset-react": "^6.1.18",
19 | "chai": "^3.5.0",
20 | "chai-jquery": "^2.0.0",
21 | "css-loader": "^0.25.0",
22 | "file-loader": "^0.9.0",
23 | "jquery": "^2.2.1",
24 | "jsdom": "^8.1.0",
25 | "mocha": "^2.4.5",
26 | "react-addons-test-utils": "^0.14.7",
27 | "react-hot-loader": "^3.0.0-beta.3",
28 | "webpack": "^1.12.9",
29 | "webpack-bundle-tracker": "0.0.93",
30 | "webpack-dev-server": "^1.14.0"
31 | },
32 | "dependencies": {
33 | "axios": "^0.9.1",
34 | "babel-preset-stage-1": "^6.1.18",
35 | "extract-text-webpack-plugin": "^1.0.1",
36 | "lodash": "^3.10.1",
37 | "node-sass": "^3.4.2",
38 | "react": "^0.14.3",
39 | "react-dom": "^0.14.3",
40 | "react-redux": "^4.0.0",
41 | "redux": "^3.0.4",
42 | "sass-loader": "^3.2.0",
43 | "style-loader": "^0.13.0"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/client/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var webpack = require('webpack');
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
4 | var BundleTracker = require('webpack-bundle-tracker')
5 |
6 | module.exports = {
7 | context: __dirname,
8 | entry: [
9 | 'webpack-dev-server/client?http://localhost:3000',
10 | 'webpack/hot/only-dev-server',
11 | './assets/js/index'
12 | //'./src/app.js'
13 | ],
14 | output: {
15 | path: path.resolve('./assets/bundles/'),
16 | filename: '[name]-[hash].js',
17 | //path: __dirname,
18 | publicPath: 'http://localhost:3000/assets/bundles/',
19 | //filename: 'bundle.js'
20 | },
21 | plugins: [
22 | new webpack.HotModuleReplacementPlugin(),
23 | new webpack.NoErrorsPlugin(),
24 | new BundleTracker({filename: './webpack.stats.json'}),
25 | new ExtractTextPlugin('style.css'),
26 | ],
27 | module: {
28 | loaders: [
29 | {
30 | test: /\.jsx?$/,
31 | exclude: /node_modules/,
32 | loaders: ['react-hot-loader/webpack', 'babel-loader?presets[]=es2015,presets[]=react'],
33 | },
34 | {
35 | test: /\.(scss|css)$/,
36 | loader: ExtractTextPlugin.extract(
37 | 'style',
38 | 'css-loader!sass'
39 | )
40 | },
41 | {
42 | test: /\.(png|jpg|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
43 | exclude: /node_modules/,
44 | loader: 'file-loader'
45 | }
46 | ]
47 | },
48 | resolve: {
49 | extensions: ['', '.js', '.jsx']
50 | },
51 | devServer: {
52 | historyApiFallback: true,
53 | contentBase: './'
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/server/settings/common.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | DEBUG = True
4 |
5 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6 |
7 | ADMINS = (
8 | # ('Your Name', 'your_email@example.com'),
9 | )
10 |
11 | MANAGERS = ADMINS
12 |
13 | # Hosts/domain names that are valid for this site; required if DEBUG is False
14 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
15 | ALLOWED_HOSTS = []
16 |
17 | # Local time zone for this installation. Choices can be found here:
18 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
19 | # although not all choices may be available on all operating systems.
20 | # In a Windows environment this must be set to your system time zone.
21 | TIME_ZONE = 'UTC'
22 |
23 | # Language code for this installation. All choices can be found here:
24 | # http://www.i18nguy.com/unicode/language-identifiers.html
25 | LANGUAGE_CODE = 'en-us'
26 |
27 | SITE_ID = 1
28 |
29 | # If you set this to False, Django will make some optimizations so as not
30 | # to load the internationalization machinery.
31 | USE_I18N = True
32 |
33 | # If you set this to False, Django will not format dates, numbers and
34 | # calendars according to the current locale.
35 | USE_L10N = False
36 |
37 | DATETIME_FORMAT = "N d, o"
38 | DATE_FORMAT = "N d, o"
39 |
40 | # If you set this to False, Django will not use timezone-aware datetimes.
41 | USE_TZ = True
42 |
43 | # Absolute filesystem path to the directory that will hold user-uploaded files.
44 | # Example: "/var/www/example.com/media/"
45 | MEDIA_ROOT = '/opt/project/media/'
46 |
47 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a
48 | # trailing slash.
49 | # Examples: "http://example.com/media/", "http://media.example.com/"
50 | MEDIA_URL = '/media/'
51 |
52 | # Absolute path to the directory static files should be collected to.
53 | # Don't put anything in this directory yourself; store your static files
54 | # in apps' "static/" subdirectories and in STATICFILES_DIRS.
55 | # Example: "/var/www/example.com/static/"
56 | STATIC_ROOT = '/opt/media/static/'
57 |
58 | # URL prefix for static files.
59 | # Example: "http://example.com/static/", "http://static.example.com/"
60 | STATIC_URL = '/static/'
61 |
62 | # Additional locations of static files
63 | STATICFILES_DIRS = (
64 | os.path.join(BASE_DIR, 'assets'),
65 | )
66 |
67 |
68 | # List of finder classes that know how to find static files in
69 | # various locations.
70 | STATICFILES_FINDERS = (
71 | 'django.contrib.staticfiles.finders.FileSystemFinder',
72 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
73 | )
74 |
75 | # Make this unique, and don't share it with anybody.
76 | SECRET_KEY = 'pux#*z$_6#f54dvv+k-=wm286d0_-n2-as1h^m_1pirtp(u*2j'
77 |
78 | TEMPLATES = [
79 | {
80 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
81 | 'DIRS': [
82 | os.path.join(BASE_DIR, 'templates'),
83 | ],
84 | 'APP_DIRS': True,
85 | 'OPTIONS': {
86 | 'context_processors': [
87 | 'django.contrib.auth.context_processors.auth',
88 | 'django.template.context_processors.debug',
89 | 'django.template.context_processors.i18n',
90 | 'django.template.context_processors.media',
91 | 'django.template.context_processors.static',
92 | 'django.template.context_processors.tz',
93 | 'django.template.context_processors.request',
94 | 'django.contrib.messages.context_processors.messages',
95 | ],
96 | 'debug': DEBUG
97 | },
98 | },
99 | ]
100 |
101 | MIDDLEWARE = (
102 | 'django.middleware.common.CommonMiddleware',
103 | 'django.contrib.sessions.middleware.SessionMiddleware',
104 | 'django.middleware.csrf.CsrfViewMiddleware',
105 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
106 | 'django.contrib.messages.middleware.MessageMiddleware',
107 | )
108 |
109 | ROOT_URLCONF = 'urls'
110 |
111 | # Python dotted path to the WSGI application used by Django's runserver.
112 | WSGI_APPLICATION = 'wsgi.application'
113 |
114 | INSTALLED_APPS = (
115 | 'django.contrib.auth',
116 | 'django.contrib.contenttypes',
117 | 'django.contrib.sessions',
118 | 'django.contrib.sites',
119 | 'django.contrib.messages',
120 | 'django.contrib.staticfiles',
121 | 'django.contrib.admin',
122 |
123 | 'rest_framework',
124 | 'webpack_loader',
125 |
126 | 'apps.core',
127 | )
128 |
129 | REST_FRAMEWORK = {
130 | 'DEFAULT_AUTHENTICATION': (
131 | 'rest_framework.authentication.SessionAuthentication',
132 | ),
133 | 'DEFAULT_PERMISSION_CLASSES': (
134 | 'rest_framework.permissions.IsAuthenticated',
135 | ),
136 | 'DEFAULT_THROTTLE_CLASSES': (
137 | 'rest_framework.throttling.AnonRateThrottle',
138 | 'rest_framework.throttling.UserRateThrottle'
139 | ),
140 | 'DEFAULT_THROTTLE_RATES': {
141 | 'anon': '100/day',
142 | 'user': '1000/day'
143 | }
144 |
145 | }
146 |
147 | # We do this so that django's collectstatic copies
148 | # our bundles to the STATIC_ROOT or syncs them to
149 | # whatever storage we use.
150 | STATICFILES_DIRS = (
151 | os.path.join(BASE_DIR, 'assets'),
152 | )
153 |
154 | WEBPACK_LOADER = {
155 | 'DEFAULT': {
156 | 'BUNDLE_DIR_NAME': 'bundles/',
157 | 'STATS_FILE': os.path.join(BASE_DIR, '../client/webpack.stats.json'),
158 | }
159 | }
160 |
161 |
162 | # A sample logging configuration. The only tangible logging
163 | # performed by this configuration is to send an email to
164 | # the site admins on every HTTP 500 error when DEBUG=False.
165 | # See http://docs.djangoproject.com/en/dev/topics/logging for
166 | # more details on how to customize your logging configuration.
167 | LOGGING = {
168 | 'version': 1,
169 | 'disable_existing_loggers': False,
170 | 'filters': {
171 | 'require_debug_false': {
172 | '()': 'django.utils.log.RequireDebugFalse'
173 | }
174 | },
175 | 'handlers': {
176 | 'mail_admins': {
177 | 'level': 'ERROR',
178 | 'filters': ['require_debug_false'],
179 | 'class': 'django.utils.log.AdminEmailHandler'
180 | }
181 | },
182 | 'loggers': {
183 | 'django.request': {
184 | 'handlers': ['mail_admins'],
185 | 'level': 'ERROR',
186 | 'propagate': True,
187 | },
188 | }
189 | }
190 |
--------------------------------------------------------------------------------