Django - Basic


What is a project?

Django has the concept of a project, which is essentially a set of global files that dictate behavior and manage one or more applications. You can think of a project as a single website with one or more apps that run underneath it like a blog, guestbook, etc.

What is the basic structure of a project?

In Django, a project basically consists of 4 files (,,, plus one or more app directories. Here are brief descriptions of the files:

  • — tells Python this is a package
  • — global URL config ("URLconf") file
  • — project-specific configuration
  • — command-line interface for apps

What is an app?

As mentioned above, a project will then contain one or more apps (one folder per app). Each of these subdirectories will have their own set of files (,,, as well as an optional app-level URLconf and a templates directory. The four most important files are:

  • — same as above
  • — data models
  • — request handlers
  • — unit tests (optional but strongly-encouraged)

In addition, an app can also be "rebranded" as an app package, a reusable piece of functionality that can be dropped into any Django project. One example of such an app package would be a full-text-search app like nonrel-search.

How can we create a new project? startproject PROJECT_NAME

How can we create a new app?

./ startapp APP_NAME
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License