Django Cookie Cutter

Wondering which is the best way to structure your Django project? The Django Cookie Cutter frameworks help one create a project with a great structure quite easily. The startproject command initializes the directory structure and required files for a standard Django project, which may be fine for learning Django, but not good to be used in production. This is where Cookiecutter exerts its power. The Cookiecutter takes care of a lot of standard tasks like installing the software dependencies, setting up testing files, and including organizing common libraries like Bootstrap and AngularJS, also generating a software license and the README file.

Cookie Cutter provides various features like:

  •  Renders Django projects with 100% test coverage
  •  Twitter Bootstrap v4.0.0 – alpha
  •  End-to-end via Hitch
  •  AngularJS
  •  12-Factor based settings via django-environ
  •  Optimized development and production settings
  •  Registration via django-allauth
  •  Comes with custom user model ready to go.
  •  Grunt build for compass and livereload
  •  Basic Email configurations for sending emails via Mailgun
  •  Media storage using Amazon S3
  •  Docker support using docker-compose for development and production
  •  Procfile for deploying to Heroku

They also provide bonus features like:

  •  Serving static files from Amazon S3 or Whitenoise
  •  Configuration for Celery and Flower(Set up in Docker only)
  •  Integration with MailHog for local email testing
  •  Integration with Sentry for error logging
  •  Integration with NewRelic for performance monitoring
  •  Integration with Opbeat for performance monitoring

Getting Started

    There are few prerequisites to be followed for installing cookiecutter. They are:

  • pip
  • virtualenv
  • PostgreSQL

First, we need to create a virtualenv for your project and activate it:

$ mkvirtualenv <virtualenv name>
$ workon <virtualenv name>

Now, we can install Cookiecutter by running the command:

$ pip install cookiecutter

Switch to the directory where you want your project to be. Now, execute the following command to generate the django project:

$ cookiecutter https://github.com/pydanny/cookiecutter-django.git

The cookiecutter runs with the cookiecutter-django repo, asking us to enter project-specific details and thus, creating the project. Optional features are asked. We could install them if needed.

That’s it! Let’s build some awesome well structured Django applications with the cookie Cutter framework.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top