The official repository is located at: https://github.com/pydanny/cookiecutter-django
Even though, the documentation is clear, I want to show you the whole process:
Install the cookiecutter
Being in your python environment, you can install it using pip:
pip install cookiecutter
Having this, now you need to locate in the folder where you want to create your project, and inside this, execute the command:
In this point you will have some questions:
Now you have a folder with your new project!
But wait! we are not done!
If we try to run migrations, we are going to get an error about a non-existing Database. So you now need to configure the DB.
Configure Postgres Database
Yes, It comes with Postgres by default, and you can change it, but definitively It’s always better to use Postgres.
Let’s prepare the Database:
I’m going to create a database example, with an user example_user, and as password i will use ‘password’.
-- Create the database project CREATE DATABASE example; -- Create user for database CREATE ROLE example_user WITH LOGIN ENCRYPTED PASSWORD 'password' CREATEDB; -- Edit September 25/2015 : -- For security Only set CREATEDB permission -- Which is required for the Django tests -- Grant privileges to the user to access database GRANT ALL PRIVILEGES ON DATABASE example TO example_user;
In this point we should have an empty database working with the specified user.
Now we need to tell Django the information of my database. To do it, you need to define an environment variable DATABASE_URL using the Django convention:
If you are under a Unix environment. The following command does the job:
After this, you should be able to run Django migrations with no problem:
python manage.py migrate
You should get something like this:
And if you got something like this, let’s run the server!
python manage.py runserver
And a beautiful starter page should be displayed: