When you are first starting out, it might be confusing for you to start a django project on your own without any guidence. In this article we will cover all the things required in starting a django project.
What is Django?
Django is a popular web framework that is open source and supports python programming language as it’s back-end programming language and that makes django more powerful. To learn django completely on your own, you can follow it’s documentation or use some online tutorials website like mine.
If you want to read about complete pathway to learn web development then you can go here.
Now let’s move on to our main topic about how to start a django project.
Create a django project.
Before start diving into creating django project, the first thing you are going to need is to install django. If you haven’t done till now, you can check this walk through.
For now i am assuming that you’ve already installed django and you already activated virtual environment and you are on the page where you want to create your django project.
To create a django project, type the following command in command prompt/terminal.
django-admin startproject demoProject
It will look like something like this in windows command prompt.
Now your project is successfully created and it is named as demoProject because we give this in the above command.
Now check the folder where you’ve created your django project.i.e your virtual environment folder and there will be a folder named demoProject and there will be some new files present. Let’s now discuss them one by one.
Your folder structure will look like this.
demoProject/ manage.py demoProject/ __init__.py settings.py urls.py wsgi.py
__init__.py a blank python which indicates that this is a python package.
settings.py contains all of the configuration settings of our django project. It is a very important file in our project where you will be configuring a lot of settings as your project goes bigger.
urls.py contains URL patterns for our django project and this file will be used for mapping urls of our entire project.
wsgi.py it contains the WSGI configuration files for our project. It basically help us to run development server and deploy our django project to production server.
manage.py This file lets us interact with our django project in many different ways. it is a command line utility. This script is responsible for all project specific tasks.
Run our django project:
let’s now move to the folder named demoProject and try to run the above project.
cd demoProject python manage.py runserver
You will see something like this.
Now your project is ready and we had run it successfully. Happy Coding!