A Django project boilerplate/template with lots of state of the art libraries and tools like:
- React, for building interactive UIs
- django-js-reverse, for generating URLs on JS
- Bootstrap 4, for responsive styling
- Webpack, for bundling static assets
- Celery, for background worker tasks
- WhiteNoise with brotlipy, for efficient static files serving
- prospector and ESLint with pre-commit for automated quality assurance (does not replace proper testing!)
For continuous integration, a CircleCI configuration .circleci/config.yml is included.
Also, includes a Heroku app.json and a working Django production.py settings, enabling easy deployments with 'Deploy to Heroku' button. Those Heroku plugins are included in app.json:
- PostgreSQL, for DB
- Redis, for Celery
- Sendgrid, for e-mail sending
- Papertrail, for logs and platform errors alerts (must set them manually)
This is a good starting point for modern Python/JavaScript web projects.
- Install Django with
pip install django, to have thedjango-admincommand available. - Open the command line and go to the directory you want to start your project in.
- Start your project using:
django-admin startproject theprojectname --extension py,yml,json --name Procfile,README.md,.env.example --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip
- Above: don't forget the
--extensionand--nameparams! (also don't forget to changetheprojectnameto your project's name). - Navigate to the project's directory through your command line.
- Install pipenv if not installed yet:
pip install pipenv(maybe you'll have to run this command as an OS superuser). - Make sure you have Python 3.6 installed.
-
pipenv install --dev - Activate the newly created virtualenv with
pipenv shell -
npm update --save -
npm update --save-dev - Check for outdated npm dependencies with
npm outdatedand update them. - Change the first line of README to the name of the project.
- Add an email address to the
ADMINSsettings variable in{{project_name}}/{{project_name}}/settings/base.py - Change the
SERVER_EMAILto the email address used to send e-mails in{{project_name}}/{{project_name}}/settings/production.py - Rename the folder
circlecito.circleciwith the commandmv circleci .circleci
After completing ALL of the above, remove this Project bootstrap section from the project README. Then follow Running below.
- Inside the
backendfolder, do the following: - Create a copy of
{{project_name}}/settings/local.py.example:
cp {{project_name}}/settings/local.py.example {{project_name}}/settings/local.py(remembering you should replace{{project_name}}with your project's name!). - Create a copy of
.env.example:
cp .env.example .env - Create the migrations for
usersapp (do this, then remove this line from the README):
python manage.py makemigrations - Run the migrations:
python manage.py migrate
- Setup editorconfig, prospector and ESLint in the text editor you will use to develop.
- Open a command line window and go to the project's directory.
pipenv install --devnpm installnpm run start- Open another command line window and go to the
backenddirectory. pipenv shellpython manage.py runserver
- Open a command line window and go to the project's directory
pipenv shellpython manage.py celery
make test
Will run django tests using --keepdb and --parallel. You may pass a path to the desired test module in the make command. E.g.:
make test someapp.tests.test_views
Just run pipenv install LIB_NAME_ON_PYPI and then pipenv lock to lock the version in Pipfile.lock file
- Manually with
prospectorandnpm run linton project root. - During development with an editor compatible with prospector and ESLint.
- Run
pre-commit installto enable the hook into your git repo. The hook will run automatically for each commit. - Run
git commit -m "Your message" -nto skip the hook if you need.
This project, as other Vinta open-source projects, is used in products of Vinta clients. We are always looking for exciting work, so if you need any commercial support, feel free to get in touch: contact@vinta.com.br
Copyright (c) 2018 Vinta Serviços e Soluções Tecnológicas Ltda. MIT License