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
2018-03-09 21:17:56 +03:00
Setting Up Development Environment
----------------------------------
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
Make sure to have the following on your host:
2015-12-01 17:09:50 +03:00
2018-03-09 21:17:56 +03:00
* virtualenv_;
* pip;
* PostgreSQL.
First things first.
#. `Create a virtualenv`_ .
#. Activate the virtualenv you have just created.
2015-12-01 17:09:50 +03:00
2018-03-09 21:17:56 +03:00
#. Install development requirements: ::
2015-09-18 19:22:55 +03:00
$ pip install -r requirements/local.txt
2018-03-09 21:17:56 +03:00
#. Create a new PostgreSQL database (note: if this is the first time a database is created on your machine you might need to alter a localhost-related entry in your `` pg_hba.conf `` so as to utilize `` trust `` policy): ::
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
$ createdb <what you've entered as the project_slug at setup stage>
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
#. Apply migrations: ::
2016-06-04 01:31:50 +03:00
$ python manage.py migrate
2018-03-09 21:17:56 +03:00
#. See the application being served through Django development server: ::
$ python manage.py runserver 0.0.0.0:8000
.. _virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/
.. _`Create a virtualenv`: https://virtualenv.pypa.io/en/stable/userguide/
2016-06-04 01:31:50 +03:00
2018-03-09 21:17:56 +03:00
Setup Email Backend
-------------------
2016-06-04 01:31:50 +03:00
2018-03-09 21:17:56 +03:00
MailHog
~~~~~~~
2016-06-04 01:31:50 +03:00
2018-03-09 21:17:56 +03:00
.. note :: In order for the project to support MailHog_ it must have been bootstrapped with `` use_mailhog `` set to `` y `` .
2016-06-12 06:50:25 +03:00
2018-03-09 21:17:56 +03:00
MailHog is used to receive emails during development, it is written in Go and has no external dependencies.
2016-06-12 06:50:25 +03:00
2018-03-09 21:17:56 +03:00
For instance, one of the packages we depend upon, `` django-allauth `` sends verification emails to new users signing up as well as to the existing ones who have not yet verified themselves.
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
#. `Download the latest MailHog release`_ for your OS.
2016-01-09 02:40:19 +03:00
2018-03-09 21:17:56 +03:00
#. Rename the build to `` MailHog `` .
2016-01-09 02:40:19 +03:00
2018-03-09 21:17:56 +03:00
#. Copy the file to the project root.
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
#. Make it executable: ::
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
$ chmod +x MailHog
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
#. Spin up another terminal window and start it there: ::
2016-06-13 15:05:43 +03:00
2018-03-09 21:17:56 +03:00
./MailHog
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
#. Check out `<http://127.0.0.1:8025/>`_ to see how it goes.
2015-11-18 14:16:25 +03:00
2018-03-09 21:17:56 +03:00
Now you have your own mail server running locally, ready to receive whatever you send it.
2016-06-13 15:05:43 +03:00
2018-03-09 21:17:56 +03:00
.. _MailHog: https://github.com/mailhog/MailHog/
.. _`properly configured`: https://docs.djangoproject.com/en/dev/topics/email/#smtp-backend
2015-09-19 00:26:29 +03:00
2018-03-09 21:17:56 +03:00
Console
~~~~~~~
.. note :: If you have generated your project with `` use_mailhog `` set to `` n `` this will be a default setup.
Alternatively, deliver emails over console via `` EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' `` .
In production, we have Mailgun_ configured to have your back!
2015-09-18 19:22:55 +03:00
2015-09-19 00:26:29 +03:00
.. _Mailgun: https://www.mailgun.com/
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
Sass Compilation & Live Reloading
---------------------------------
If you’ d like to take advantage of live reloading and Sass / Compass CSS compilation you can do so with a little bit of preparation_.
.. _`Download the latest MailHog release`: https://github.com/mailhog/MailHog/releases
.. _preparation: https://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html
Summary
-------
2015-09-18 19:22:55 +03:00
2018-03-09 21:17:56 +03:00
Congratulations, you have made it! Keep on reading to unleash full potential of Cookiecutter Django.