0% found this document useful (0 votes)
8 views3 pages

Django - Creating A Project

Uploaded by

ravindranp9925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Django - Creating A Project

Uploaded by

ravindranp9925
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Django Creating Project https://www.tutorialspoint.com/django/django_creating_project.

htm

Home Whiteboard AI Assistant Online Compilers Jobs Tools Articles

Chapters Categories

SQL HTML CSS Javascript Python Java C C++ PHP Scala

Django - Creating a Project

Now that we have installed Django, let's start using it. In Django, every web app you
want to create is called a project; and a project is a sum of applications. An
application is a set of code files relying on the MVT pattern. As example let's say we
want to build a website, the website is our project and, the forum, news, contact
engine are applications. This structure makes it easier to move an application between
projects since every application is independent.

Create a Project
Whether you are on Windows or Linux, just get a terminal or a cmd prompt and
navigate to the place you want your project to be created, then use this code −

$ django-admin startproject myproject

This will create a "myproject" folder with the following structure −

myproject/
manage.py
myproject/
__init__.py
settings.py
urls.py
wsgi.py

The Project Structure


The myproject folder is just your project container, it actually contains two elements −

1 of 6 09-06-2025, 22:35
Django Creating Project https://www.tutorialspoint.com/django/django_creating_project.htm

manage.py − This file is kind of your project local django-admin for


interacting with your project via command line (start the development server,
sync db...). To get a full list of command accessible via manage.py you can use
the code −

$ python manage.py help

The myproject subfolder − This folder is the actual python package of your
project. It contains four files −

__init__.py − Just for python, treat this folder as package.

settings.py − As the name indicates, your project settings.

urls.py − All links of your project and the function to call. A kind of ToC
of your project.

wsgi.py − If you need to deploy your project over WSGI.

Setting Up Your Project


Your project is set up in the subfolder myproject/settings.py. Following are some
important options you might need to set −

DEBUG = True

This option lets you set if your project is in debug mode or not. Debug mode lets you
get more information about your project's error. Never set it to True for a live project.
However, this has to be set to True if you want the Django light server to serve static
files. Do it only in the development mode.

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'database.sql',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}

2 of 6 09-06-2025, 22:35
Django Creating Project https://www.tutorialspoint.com/django/django_creating_project.htm

Database is set in the Database dictionary. The example above is for SQLite engine.
As stated earlier, Django also supports −

MySQL (django.db.backends.mysql)

PostGreSQL (django.db.backends.postgresql_psycopg2)

Oracle (django.db.backends.oracle) and NoSQL DB

MongoDB (django_mongodb_engine)

Before setting any new engine, make sure you have the correct db driver installed.

You can also set others options like: TIME_ZONE, LANGUAGE_CODE, TEMPLATE

Now that your project is created and configured make sure it's working −

$ python manage.py runserver

You will get something like the following on running the above code −

Validating models...

0 errors found
September 03, 2015 - 11:41:50
Django version 1.6.11, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

3 of 6 09-06-2025, 22:35

You might also like