Open In App

How to Create a Project in Django

Last Updated : 14 Nov, 2025
Suggest changes
Share
67 Likes
Like
Report

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.

Step 3: Configure URLs

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-project
File structure of the project

Step 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.

image
Snapshot of /geeks url

Related Post:

Suggested Quiz
3 Questions

Which command creates a new Django project folder with the initial project files?

  • A

    python manage.py startapp project_name

  • B

    python -m venv project_name

  • C

    pip install django project_name

  • D

    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?

  • A

    settings.py

  • B

    models.py

  • C

    views.py

  • D

    urls.py

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?

  • A

    start project → runserver → create view → set URL → open browser

  • B

    start project → create view → set URL → runserver → open browser

  • C

    create view → start project → runserver → set URL → open browser

  • D

    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