<< All Blog Posts
Getting Started with Django

Getting Started with Django

Django is pretty easy to pick up. The only prerequisite for starting to learn and use Django is to have some Python experience.

And if you follow the Two Scoops of Django best practice guidelines to structure your project, getting started can be even easier. Each application you create as an add-on has the same structure, which makes it pretty straightforward to figure out where things are located.

In terms of technical requirements, you'll need Python and SQLite as the back end database to start learning. Most people switch to PostgreSQL database for production use.

How to get started

Cookiecutter can create an intitial project structure for you. Install it with pip and then run it with the url for the repository:

$ pip install "cookiecutter>=1.4.0"
$ cookiecutter https://github.com/pydanny/cookiecutter-django

Cookiecutter will ask you a series of questions about your project and then create the directory tree and boilerplate for you. This is easier than using Django's startproject command and then editing the files as needed. More information about the optons is available in the Cookiecutter documentation.

Cloning into 'cookiecutter-django'...
remote: Counting objects: 550, done.
remote: Compressing objects: 100% (310/310), done.
remote: Total 550 (delta 283), reused 479 (delta 222)
Receiving objects: 100% (550/550), 127.66 KiB | 58 KiB/s, done.
Resolving deltas: 100% (283/283), done.
project_name [Project Name]: Your Project
project_slug [reddit_clone]: yourproject
author_name [Your Name]: Your Name
email [you@example.com]: you@example.com
description [A short description of the project.]: A short description of the project.
domain_name [example.com]: example.com
version [0.1.0]: 0.0.1
timezone [UTC]: America/Indiana/Indianapolis
use_whitenoise [y]: n
use_celery [n]: n
use_mailhog [n]: n
use_sentry_for_error_reporting [y]: n
use_opbeat [n]: n
use_pycharm [n]: y
windows [n]: n
use_python3 [y]: y
use_docker [y]: n
use_heroku [n]: n
use_compressor [n]: y
Select postgresql_version:
1 - 9.5
2 - 9.4
3 - 9.3
4 - 9.2
Choose from 1, 2, 3, 4 [1]: 1
Select js_task_runner:
1 - Gulp
2 - Grunt
3 - None
Choose from 1, 2, 3, 4 [1]: 1
use_lets_encrypt [n]: n
Select open_source_license:
1 - MIT
2 - BSD
3 - GPLv3
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 [1]: 1
use_elasticbeanstalk_experimental: n

There is also additional information provided for accommodations for local development.

From there you could do the official Django tutorial for creating an app or learn by building a custom Django app that is used in a real world project as an example to see how everything is hooked up, and follow that in the app that you are working on.

The Django Documenatation provides a lot of information, and Stack Overflow is always a big help.

And obviously, asking questions to seasoned Django developers greatly helps when you are stuck with a problem.

Django's Wins & Pitfalls

Pros:

  • Django has an easy to understand file structure that is easy to navigate. Especially if using Cookiecutter to keep it all consistent.
  • Since it's using Python, I had no trouble getting comfortable working with Django.
  • The template language was easy to pick up, and has some helpful features.

Cons:

  • You can't use Python in the templates at all (which is a mix of good and bad)
  • It can be hard to figure out when things happen automagically - many things in Django "just work" when a specific name is used. It's handy but confusing when you are first starting out. You can't always trace a path to figure out how something is working.

Tips and Advice

  • Find examples of projects online to follow, or go through a tutorial like Eleven Note.
  • This repository of projects used on a personal blog by Krzysztof Żuraw is one that helped me.
  • Classy Class Based Views is a site with full information of each class based view available in Django. Use class based views FTW!
Strategy Guide Photo

Save Time With Django Strategy Guides

Save time in your Django development projects: download our free strategy guides on Django Filters and Django Tag Templates.


Thanks for filling out the form! A Six Feet Up representative will be in contact with you soon.

Connect with us