0% found this document useful (0 votes)
7 views

Django Project Guide

This document provides a step-by-step guide to creating a Django project, starting from installing Django to setting up a basic project structure. It includes commands for creating a project, running a development server, creating an app, registering the app, applying migrations, and creating a superuser for the admin panel. By following these steps, users can successfully set up a basic Django project and access the admin interface.

Uploaded by

ANIK DUTTA
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)
7 views

Django Project Guide

This document provides a step-by-step guide to creating a Django project, starting from installing Django to setting up a basic project structure. It includes commands for creating a project, running a development server, creating an app, registering the app, applying migrations, and creating a superuser for the admin panel. By following these steps, users can successfully set up a basic Django project and access the admin interface.

Uploaded by

ANIK DUTTA
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 Project Creation Guide

Step 1: Install Django

Ensure you have Python installed (preferably 3.8+). Then, install Django using pip:

pip install django

Step 2: Create a Django Project

Run the following command to create a new Django project:

django-admin startproject project_name

Example:

django-admin startproject myproject

This will create a directory structure like this:

myproject/

- manage.py

- myproject/

- __init__.py

- settings.py

- urls.py

- asgi.py

- wsgi.py

Step 3: Navigate to the Project Directory

cd myproject
Step 4: Run the Development Server

To check if everything is working, run:

python manage.py runserver

You should see output like:

Starting development server at http://127.0.0.1:8000/

Open a browser and go to http://127.0.0.1:8000/, and you should see the Django welcome page.

Step 5: Create a Django App

Inside your project, create an app to handle specific functionalities:

python manage.py startapp app_name

Example:

python manage.py startapp blog

This creates a folder structure like:

blog/

- migrations/

- __init__.py

- admin.py

- apps.py

- models.py

- tests.py

- views.py
Step 6: Register the App in settings.py

In myproject/settings.py, add 'blog' to the INSTALLED_APPS list:

INSTALLED_APPS = [

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

'blog', # Add your app here

Step 7: Apply Migrations

python manage.py migrate

Step 8: Create a Superuser (For Admin Panel)

python manage.py createsuperuser

Follow the prompts to enter a username, email, and password.

Step 9: Run the Server and Access the Admin Panel

Start the server:

python manage.py runserver

Go to http://127.0.0.1:8000/admin/ and log in with your superuser credentials.

Now, you have a basic Django project set up!

You might also like