base/project/:

project / manage.py:

python manage.py runserver

python manage.py

project/project:

project/project /__init__.py:

project/project /settings.py:

project/project /urls.py:

project/project /uwsgi.py:

project/static:

project/templates:

project/media:

import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) MEDIA_ROOT = os.path.join(BASE_DIR + '/media/') MEDIA_URL = '/media/' STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, "static"), ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ["templates"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ]

project/ app1:

project/app1/templatetags:

project/app1/templatetags/__init__.py:

project/app1/templatetags/tags.py:

project/app1/apps.py:

project/app1/models.py:

project/app1/migrations:

project/app1/migrations/__init__.py:

project/app1/migrations/001_initial.py:

project/app1/__init__.py:

project/app1/admin.py:

project/app1/urls.py:

project/app1/views.py:

project/app1/tests.py:





Let's talk about "Django" project structure in depth. You can see the complete project layout in above image.It is a container for our project. we can give any name to this directory and we can modify it at any time.It is created for all django projects. It is a command-line utility, it is used to interact with the "django" project in many ways.We use below command to run development server"runserver" is a command which is used to run the server.To show all available commands run the below commandThis directory contains the project files.It is a empty file that tells python to consider the directory as a package. It contains all configuration settings like database settings, installed apps, root url conf etc.It is the root url file. It contains url patterns to map the request to the respective view to process it.An entry-point for WSGI-compatible web servers to serve our project.It contains the static assets like css, javascript, images, etc.It contains the html files that will be used to create http response to a request.It is a path to store the media contents like files that are uploaded by users.To get project structure that is shown in above image. we need to updatefile with below code.To know more about customizing settings visit: https://docs.djangoproject.com/en/1.10/ref/settings/ It is a python package, It contains application related files.It's a directory that contains template tags of our application. Template tags helps us at the time of rendering the template. It takes the context from the template and processes it and again return it to the template.It's empty python file, it tells python to recognize the directory as a python package.It's a python file, it contains the custom template tags that we will use it in templates.It contains the application's configuration.It contains the models(db tables) of application. we represent our database tables with the model in django. ORM(Object Relation Mapper) converts the models to db tables. We do not use raw SQL(Structured Query Language) to query the database, instead we use django queries. ORM convert these queries into SQL equivalent code and performs the db query and again converts the relational data to python objects to make things easier.It contains the database migrations of application, each migration contains the database schema related code.It's empty python file, it tells python to recognize the directory as a python package.It's a migration file of application. It contains the database schema related code, that is used to create database schema.It's a python file, it tells python to recognize the directory as a python package.Django provides the inbuilt admin panel.This file contains the admin related code.It contains url's that are related to the application.It contains the views(functions/classes) that are mapped from the url's to process the request.It contains the unit tests of the application.