Getting Up and Running Locally¶
The steps below will get you up and running with a local development environment. We assume you have the following installed:
First make sure to create and activate a virtualenv.
Then install the requirements for your local development:
$ pip install -r requirements/local.txt
Then, create a PostgreSQL database with the following command, where [project_slug] is what value you entered for your project’s project_slug:
$ createdb [project_slug]
You can now run the usual Django
$ python manage.py migrate $ python manage.py runserver
At this point you can take a break from setup and start getting to know the files in the project.
But if you want to go further with setup, read on.
(Note: the following sections still need to be revised)
Setting Up Env Vars for Production¶
Cookiecutter Django uses the excellent django-environ package, which includes a
DATABASE_URL environment variable to simplify database configuration in your Django settings.
Rename env.example to .env to begin updating the file with your own environment variables. To add your database, define
DATABASE_URL and add it to the .env file, as shown below:
Setup your email backend¶
django-allauth sends an email to verify users (and superusers) after signup and login (if they are still not verified). To send email you need to configure your email backend
In development you can (optionally) use MailHog for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:
- Download the latest release for your operating system
- Rename the executable to
mailhogand copy it to the root of your project directory
- Make sure it is executable (e.g.
chmod +x mailhog)
- Execute mailhog from the root of your project in a new terminal window (e.g.
- All emails generated from your django app can be seen on http://127.0.0.1:8025/
Alternatively simply output emails to the console via:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
In production basic email configuration is setup to send emails with Mailgun
Live reloading and Sass CSS compilation
If you’d like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of prep work.