๐ Getting Started with Django: A Two-App Project with Individual Templates
As a beginner learning Django, I wanted to go beyond the usual single-app setup and try something more practical: a Django project with two apps, where each app has its own templates.
This post walks you through exactly how I set it up โ with actual code and screenshots from my own project. If youโre getting started or want to organize your project more cleanly, this guide is for you. ๐ง โจ
๐๏ธ Folder Structure
Hereโs what the structure looks like in my project:
web_project/
โ
โโโ hello/
โ โโโ templates/
โ โ โโโ hello/
โ โ โโโ sample.html
โ โ โโโ sample.css
โ โโโ views.py
โ โโโ urls.py
โ
โโโ users/
โ โโโ templates/
โ โ โโโ users/
โ โ โโโ register.html
โ โโโ views.py
โ โโโ urls.py
โ
โโโ web_project/
โ โโโ settings.py
โ โโโ urls.py
โโโ manage.py
โ Step-by-Step Setup
โ๏ธ Step 0: Set Up a Virtual Environment
Before we even touch Django, let's set up a clean Python environment for the project.
-
Create a virtual environment (you can name it
venvor anything):
python -m venv venv
- Activate it:
- On Windows:
venv\Scripts\activate
- On Linux/macOS:
source venv/bin/activate
- Install Django:
pip install django
Once Django is installed inside your virtual environment, youโre ready to create your Django project!
1. Create the Project and Apps
django-admin startproject web_project
cd web_project
python manage.py startapp hello
python manage.py startapp users
2. Register Apps in settings.py
INSTALLED_APPS = [
...
'hello',
'users',
]
3. Write Your Views
hello/views.py
from django.shortcuts import render
def hello(request):
return render(request, 'hello/sample.html')
๐ธ Hereโs how my code looks in VS Code:
4. Create Templates
๐ hello/templates/hello/sample.html
<!DOCTYPE html>
<html>
<head>
<title>About django</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a sample Django web project.</p>
<p>Welcome to the Hello World page!</p>
</body>
</html>
๐ธ Hereโs my actual file in action:
๐ users/templates/users/register.html
<h2>This is the user registration page</h2>
5. Set Up URL Routing
hello/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.hello, name='hello'),
]
users/urls.py
from django.urls import path
from . import views
def register(request):
return render(request, 'users/register.html')
urlpatterns = [
path('', register, name='register'),
]
web_project/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', include('hello.urls')),
path('users/', include('users.urls')),
]
6. Run the Server
python manage.py runserver
Now open your browser and visit:
- http://127.0.0.1:8000/hello/ โ Youโll see the "Hello, World!" template
- http://127.0.0.1:8000/users/ โ Youโll see the user register page
๐ง Key Takeaways
- Each app can and should have its own
templates/folder for better organization. - Always remember to include each appโs URL configuration inside the main project
urls.py. - Restart the dev server when you make changes to settings or URL configurations.
๐ฌ Final Thoughts
Setting this up helped me understand Djangoโs project structure and how templates work. It also taught me how to keep things clean when scaling to multiple apps.
Let me know in the comments if you're trying something similar or hit a wallโIโll be happy to help out!
Would you like this in Markdown format or as a PDF export ready for Dev.to upload?
By: Vall Achieng
As a beginner learning Django, I wanted to go beyond the usual single-app setup and try something more practical: a Django project with two apps, where each app has its own templates.
This post walks you through exactly how I set it up โ with actual code and screenshots from my own project. If youโre getting started or want to organize your project more cleanly, this guide is for you. ๐ง โจ
๐๏ธ Folder Structure
Hereโs what the structure looks like in my project:
web_project/
โ
โโโ hello/
โ โโโ templates/
โ โ โโโ hello/
โ โ โโโ sample.html
โ โ โโโ sample.css
โ โโโ views.py
โ โโโ urls.py
โ
โโโ users/
โ โโโ templates/
โ โ โโโ users/
โ โ โโโ register.html
โ โโโ views.py
โ โโโ urls.py
โ
โโโ web_project/
โ โโโ settings.py
โ โโโ urls.py
โโโ manage.py
โ Step-by-Step Setup
1. Create the Project and Apps
django-admin startproject web_project
cd web_project
python manage.py startapp hello
python manage.py startapp users
2. Register Apps in settings.py
INSTALLED_APPS = [
...
'hello',
'users',
]
3. Write Your Views
hello/views.py
from django.shortcuts import render
def hello(request):
return render(request, 'hello/sample.html')
๐ธ Hereโs how my code looks in VS Code:
4. Create Templates
๐ hello/templates/hello/sample.html
<!DOCTYPE html>
<html>
<head>
<title>About django</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a sample Django web project.</p>
<p>Welcome to the Hello World page!</p>
</body>
</html>
๐ธ Hereโs my actual file in action:
๐ users/templates/users/register.html
<h2>This is the user registration page</h2>
5. Set Up URL Routing
hello/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.hello, name='hello'),
]
users/urls.py
from django.urls import path
from . import views
def register(request):
return render(request, 'users/register.html')
urlpatterns = [
path('', register, name='register'),
]
web_project/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('hello/', include('hello.urls')),
path('users/', include('users.urls')),
]
6. Run the Server
python manage.py runserver
Now open your browser and visit:
- http://127.0.0.1:8000/hello/ โ Youโll see the "Hello, World!" template
- http://127.0.0.1:8000/users/ โ Youโll see the user register page
๐ง Key Takeaways
- Each app can and should have its own
templates/folder for better organization. - Always remember to include each appโs URL configuration inside the main project
urls.py. - Restart the dev server when you make changes to settings or URL configurations.
๐ฌ Final Thoughts
Setting this up helped me understand Djangoโs project structure and how templates work. It also taught me how to keep things clean when scaling to multiple apps.
Let me know in the comments if you're trying something similar or hit a wallโIโll be happy to help out!

Top comments (0)