Django Overview

Framework basic summary

Last modified:


Each Django project can be composed of many apps. An app is a small project that should focus on performing one task (e.g. A website project can have: a blog, ratings, news apps).

Django project structure

A typical Django project, at first, has a very basic layout. After following Django docs suggestions, like creating the project $ django-admin startproject my_project and some app $ python startapp my_app will create the following structure:

└── mysite/
    β”œβ”€β”€ mysite/
    |   β”œβ”€β”€
    |   β”œβ”€β”€
    |   β”œβ”€β”€
    |   └──
    └── myapp/
        β”œβ”€β”€ migrations/
Default settings are located in django/conf/, they are overwritten in mysite/

The structure that sets up Django by default is very basic, when a project starts to grow, it starts to require a better approach, outlined in Django directory structure that deals with other aspects of development and deployment such as:

  • deployment scripts
  • separated tests by units
  • having different environments for development, production (staging)
  • documentation for the project


Fat models, thin views.




In a Django web app, a form can refer to:

  • an HTML form a component of a Web page that has form controls
  • a Django Form that produces an HTML form
  • the structured data returned when a form is submitted
  • all of the above interacting together
Django handles three distinct parts of the work involved in forms
  1. preparing and restructuring data to make it ready for rendering
  2. creating HTML forms for the data
  3. receiving and processing submitted forms and data from the client tutorial

Most of the forms in Django should be created from models, using ModelForms, Model Fields and CSRF protection.

ModelForms are useful to:

A ModelForm maps fields from model classes to HTML form <input> elements via a the Form class.

One of the core features of Django Forms is that they make it easy to validate all the data.

Form methods

If the form is used to retrieve data, it should use the GET method, if it modifies data, it needs to use the POST method.



The preferred way to write tests in Django is using the unittest module built in to the Python standard library

In Django we subclasses from django.test.TestCase, which is a subclass of unittest.TestCase that runs each test inside a transaction to provide isolation.

Django provides a test Client to simulate a user interacting with the code at the view level. We can use it in



*[ORM]: Object Relational Mapping

Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus

Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 . Terms and Policy.

Powered by SimpleIT Hugo Theme