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/
- [Link]
- myproject/
- __init__.py
- [Link]
- [Link]
- [Link]
- [Link]
Step 3: Navigate to the Project Directory
cd myproject
Step 4: Run the Development Server
To check if everything is working, run:
python [Link] runserver
You should see output like:
Starting development server at [Link]
Open a browser and go to [Link] 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 [Link] startapp app_name
Example:
python [Link] startapp blog
This creates a folder structure like:
blog/
- migrations/
- __init__.py
- [Link]
- [Link]
- [Link]
- [Link]
- [Link]
Step 6: Register the App in [Link]
In myproject/[Link], add 'blog' to the INSTALLED_APPS list:
INSTALLED_APPS = [
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'blog', # Add your app here
Step 7: Apply Migrations
python [Link] migrate
Step 8: Create a Superuser (For Admin Panel)
python [Link] 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 [Link] runserver
Go to [Link] and log in with your superuser credentials.
Now, you have a basic Django project set up!