Create Django Project

Creating a Django project involves a few simple steps. Here’s a guide to help you get started:

Step 1: Ensure Django is Installed

Make sure Django is installed on your system. Check by running:


python -m django --version
If Django is not installed, follow the URL

Step 2: Create a New Project

Run the following command to create a new Django project:


django-admin startproject project_name

Replace project_name with the name of your project like myproject.

This creates a directory named project_name containing the following structure:


project_name/
    manage.py
    project_name/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py

manage.py: A command-line utility for interacting with the project.

settings.py: Configuration settings for the project.

urls.py: URL declarations for routing.

asgi.py: Entry point for ASGI applications (for asynchronous features).

wsgi.py: Entry point for WSGI applications (for traditional web servers).

Step 3: Navigate to the Project Directory

Change to the project directory:


cd project_name

Step 4: Start the Development Server

Run the following command to start Django’s built-in development server:


python manage.py runserver

The server will start, and you’ll see output like this:


Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Open a web browser and go to:


http://127.0.0.1:8000/

You should see the default Django welcome page, which confirms that the project was created successfully.

Create Django Project – Interview Questions

Q 1: How do you create a Django project?

Ans: django-admin startproject projectname

Q 2: What files are created in a Django project?

Ans: settings.py, urls.py, wsgi.py, asgi.py, and manage.py.

Q 3: What is manage.py?

Ans: A command-line utility to interact with the Django project.

Q 4: What is settings.py used for?

Ans: It contains configuration settings for the project.

Q 5: What is the default database used by Django?

Ans: SQLite.

Create Django Project – Objective Questions (MCQs)

Q1. Which command creates a new Django project?






Q2. A Django project contains which important file?






Q3. Which file in a Django project contains URL settings?






Q4. Which command runs the Django development server?






Q5. The default SQLite database file created inside a new project is:






Related Create Django Project Topics