2015-09-18 19:22:55 +03:00
Getting Up and Running Locally
==============================
2015-09-19 00:26:29 +03:00
.. index :: pip, virtualenv, PostgreSQL
2015-09-18 19:22:55 +03:00
The steps below will get you up and running with a local development environment. We assume you have the following installed:
* pip
* virtualenv
* PostgreSQL
2016-06-04 01:31:50 +03:00
First make sure to create and activate a virtualenv_.
2015-12-01 17:09:50 +03:00
2016-06-04 01:31:50 +03:00
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
2015-12-01 17:09:50 +03:00
Then install the requirements for your local development::
2015-09-18 19:22:55 +03:00
$ pip install -r requirements/local.txt
2016-04-20 21:41:17 +03:00
Then, create a PostgreSQL database with the following command, where `[project_slug]` is what value you entered for your project's `project_slug` ::
2015-09-18 19:22:55 +03:00
2016-04-20 21:41:17 +03:00
$ createdb [project_slug]
2015-09-18 19:22:55 +03:00
2016-06-04 01:31:50 +03:00
You can now run the usual Django `` migrate `` and `` runserver `` commands::
$ python manage.py migrate
$ python manage.py runserver
2016-06-12 06:50:25 +03:00
At this point you can take a break from setup and start getting to know the files in the project.
2016-06-04 01:31:50 +03:00
2016-06-12 06:50:25 +03:00
But if you want to go further with setup, read on.
2016-06-04 01:31:50 +03:00
(Note: the following sections still need to be revised)
Setting Up Env Vars for Production
-----------------------------------
2016-06-12 06:50:25 +03:00
`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:
2015-09-18 19:22:55 +03:00
2016-01-09 02:40:19 +03:00
.. parsed-literal ::
2016-06-12 06:50:25 +03:00
DATABASE_URL="postgres://*<pg_user_name>* :*<pg_user_password>* \ @127.0.0.1:\ *<pg_port>* /*<pg_database_name>* "
2016-01-09 02:40:19 +03:00
2016-05-09 23:18:58 +03:00
.. _django-environ: http://django-environ.readthedocs.io
2015-09-18 19:22:55 +03:00
2016-06-04 01:31:50 +03:00
Setup your email backend
-------------------------
2015-09-18 19:22:55 +03:00
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`_
2015-12-09 15:33:17 +03:00
.. _configure your email backend: http://docs.djangoproject.com/en/1.9/topics/email/#smtp-backend
2016-06-13 15:05:43 +03:00
In development you can (optionally) use MailHog_ for email testing. MailHog is built with Go so there are no dependencies. To use MailHog:
2015-09-18 19:22:55 +03:00
2015-11-18 14:16:25 +03:00
1. `Download the latest release`_ for your operating system
2. Rename the executable to `` mailhog `` and copy it to the root of your project directory
3. Make sure it is executable (e.g. `` chmod +x mailhog `` )
2016-05-09 21:33:21 +03:00
4. Execute mailhog from the root of your project in a new terminal window (e.g. `` ./mailhog `` )
5. All emails generated from your django app can be seen on http://127.0.0.1:8025/
2015-11-18 14:16:25 +03:00
.. _Mailhog: https://github.com/mailhog/MailHog/
.. _Download the latest release: https://github.com/mailhog/MailHog/releases
2016-06-13 15:05:43 +03:00
2015-11-18 14:16:25 +03:00
Alternatively simply output emails to the console via: `` EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ``
2015-09-19 00:26:29 +03:00
2015-09-18 19:22:55 +03:00
In production basic email configuration is setup to send emails with Mailgun_
2015-09-19 00:26:29 +03:00
.. _Mailgun: https://www.mailgun.com/
2015-09-18 19:22:55 +03:00
**Live reloading and Sass CSS compilation**
2016-06-13 15:12:32 +03:00
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`_ .
2015-09-18 19:22:55 +03:00
2016-06-13 15:12:32 +03:00
.. _prep work: https://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html