How to Create a Project in Django
Last Updated : 14 Nov, 2025
A Django project is the main folder structure for a web application, containing settings, URLs, and apps. It sets up the environment for development.
Steps to create apps in Django
Before creating a Django project, ensure that a virtual environment is set up and Django is installed within it.
Step 1: Create the Project
Once the environment is activated and Django is available, a new project can be created using:
django-admin startproject projectName
This will create a new folder named projectName.
Change into your project directory:
cd projectName
Step 2: Create a View
Inside your project folder (where settings.py and urls.py are located), create a new file named views.py. and add the following code to views.py:
Python from django.http import HttpResponse def hello_geeks(request): return HttpResponse("Hello Geeks") This simple view returns the string "Hello Geeks" when accessed.
In the urls.py file inside the project folder (projectName/urls.py) and modify it as follows:
1. Import view at the top:
from projectName.views import hello_geeks
2. Add a URL pattern inside the urlpatterns list to link view:
Python from django.urls import path from projectName.views import hello_geeks urlpatterns = [ path('geek/', hello_geeks), ] This routes any request to /geek/ to the hello_geeks view.
After following these steps, file structure should look like this:
File structure of the projectStep 4: Run the Development Server
Ensure the virtual environment is activated, then start the Django development server:
python manage.py runserver
In web browse, visit:
http://127.0.0.1:8000/geek/
The message "Hello Geeks" should be displayed.
Snapshot of /geeks urlRelated Post:
Which command creates a new Django project folder with the initial project files?
-
python manage.py startapp project_name
-
python -m venv project_name
-
pip install django project_name
-
django-admin startproject project_name
Explanation:
startproject generates the main Django project structure.
After creating a project, what file needs to be modified to connect a URL path to a view function?
Explanation:
The urls.py file maps incoming URLs to the corresponding view functions.
What is the correct order to display a simple response in a browser?
-
start project → runserver → create view → set URL → open browser
-
start project → create view → set URL → runserver → open browser
-
create view → start project → runserver → set URL → open browser
-
create view → set URL → restart project → runserver
Explanation:
After starting the project, a view is created, the URL is mapped, the server is started, and then the browser can display the output.
Quiz Completed Successfully
Your Score : 2/3
Accuracy : 0%
Login to View Explanation
1/3 1/3 < Previous Next >
Explore
Python Fundamentals
Python Data Structures
Advanced Python
Data Science with Python
Web Development with Python
Python Practice
My Profile