Introduction
Hello, today is my fourth day of the 20 days of Django and I am excited to share what I did. I worked on my project structure. Stay with me..
Since I already installed django and python, I was set to begin.
Step 1: Create a Django Project
Open a terminal (or PyCharm terminal) and run:
django-admin startproject ProjectTG
cd ProjectTG
This creates the ProjectTG
folder with the main project files.
Step 2: Create Two Django Apps
Letβs name them blog
and store
This creates two new folders: blog/
and store/
.
Step 3: Register Apps in settings.py
In ProjectTG/settings.py
, add your apps:
Step 4: Set Up Templates Directory
Still in settings.py
, configure Django to look in a templates
directory:
Then, I created this structure:
Also create templates
folders in each app:
Step 5: Define Views for Each App
Each app will have two views.
blog/views.py
store/views.py
Step 6: Create URL Configs
In ProjectTG/urls.py
:
Create blog/urls.py
:
Create store/urls.py
:
Step 7: Add Templates
Create these HTML files:
blog/templates/blog/home.html
blog/templates/blog/about.html
store/templates/store/home.html
store/templates/store/products.html
Step 9: Run the Server
Start the Django development server:
Conclusion
The process was a little bit challenging but I am glad I managed
Top comments (0)