Your First Django Project and App: uv, startproject, startapp and a First View
Set up a Django project called blogproject with uv, add an app called blog, write one view that returns Hello blog, give it the empty path and run the server. Every command with its real output.
What you will learn
- Create a Django project with uv init, uv add django and startproject
- Tell the project package apart from an app made with startapp
- Register an app in INSTALLED_APPS and wire a view to a URL
- Read the runserver output, including the migrations note and the 404 page
Before you start
- Python functions
- uv or virtual environments
- HTTP requests and status codes
Think of a restaurant kitchen. The whole kitchen has one set of house rules and one front door where the orders come in. Inside it there are stations, like the grill and the pastry corner, and each one does a single job with its own tools.
In Django, the whole kitchen is the project. It holds the settings and the main list of URLs. Each station is an app, and each app holds one feature. Our blog will be one app called blog, inside a project called blogproject. By the end, your browser shows a page that came from your own code.
A uv project with Django
Start with an empty folder and a terminal. If you've used uv before, this will feel familiar (if not, see setting up a Python project with uv).
uv init --bare
uv add django
Initialized project `s01l02-firstapp`
Using CPython 3.12.14
Creating virtual environment at: .venv
Resolved 5 packages in 6ms
Installed 4 packages in 3.46s
+ asgiref==3.13.0
+ django==6.1.3
+ sqlparse==0.6.1
+ tzdata==2026.6
uv init --bare creates just one file, pyproject.toml. uv add django creates a virtual environment in .venv and installs Django 6.1.3. Django brings three helper packages with it, asgiref, sqlparse and tzdata. These are dependencies, and uv installs them for you.
Django is now written in the dependencies list:
[project]
name = "s01l02-firstapp"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"django>=6.1.3",
]
uv.lock pins the exact versions, so anyone can rebuild the same setup. The commands work the same in PowerShell or a Linux shell.
Creating the project
uv run django-admin startproject blogproject .
uv run runs the command inside the virtual environment, so you don't have to activate anything first. The dot at the end matters: it says "build the project right here". Without it you'd get one more folder wrapped around everything.
The command prints nothing, and that's fine. Two things appear: manage.py at the top of the folder, and a package called blogproject.
Inside blogproject
settings.pyholds the house rules, like the list of installed apps and the database.urls.pyis the front door. Every request that comes in is matched against the list in here. It already has one entry,admin/.wsgi.pyandasgi.pyare how a production web server talks to the project once it's deployed. We won't touch them now.__init__.pyis empty. It makesblogprojecta Python package.
manage.py, outside the package, is the helper you run every command through, like startapp and runserver. So the project has rules and a front door, but no feature yet.
Creating the blog app
uv run python manage.py startapp blog
A new folder called blog appears next to blogproject. This is the tree after both commands, straight from the run:
blog/
blog/__init__.py
blog/admin.py
blog/apps.py
blog/migrations/
blog/migrations/__init__.py
blog/models.py
blog/tests.py
blog/views.py
blogproject/
blogproject/__init__.py
blogproject/asgi.py
blogproject/settings.py
blogproject/urls.py
blogproject/wsgi.py
manage.py
pyproject.toml
uv.lock
In the app, models.py is where the data shapes go, and migrations keeps a record of the database changes those models need. views.py holds the code that answers a request. admin.py shows your data in Django's admin, and apps.py describes the app itself; its name is blog. tests.py is a place for tests.
Telling the project about the app
This is the step people forget. Creating the folder isn't enough, because the project doesn't know about the app yet. In blogproject/settings.py, add 'blog' at the end of INSTALLED_APPS:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
Django matches that name with apps.py, and now the app is part of the project. The apps above it came with Django. While you're in the file, look at DATABASES: Django uses SQLite by default, a database stored in a single file, db.sqlite3.
Our first view
Open blog/views.py:
from django.http import HttpResponse
def home(request):
return HttpResponse("Hello blog, my first app.")
When someone visits the page, Django builds a request object and passes it in. The function returns an HttpResponse with some text. A view is just a Python function: a request goes in, a response comes out. But right now nobody can reach it, because no URL points to it.
A URL for the view
In blogproject/urls.py, import the views and add a path (the long docstring Django generates is left out here):
from django.contrib import admin
from django.urls import path
from blog import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home),
]
The empty string means the home page, the address with nothing after the slash. Notice views.home has no brackets. You're handing the function to Django, and Django calls it later when a request arrives.
Running the server
First ask Django to check your work:
uv run python manage.py check
System check identified no issues (0 silenced).
Then start the development server:
uv run python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
November 09 - 00:50:11
Django version 6.1.3, using settings 'blogproject.settings'
Starting WSGI development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead.
For more information on production servers see: https://docs.djangoproject.com/en/6.1/howto/deployment/
The 18 unapplied migrations are normal for a new project. They are the tables of Django's own apps, and you apply them when you build your first model (see models, migrations and the admin). Then come the version, the settings in use and the address, port 8000. Please read the warning: this server is for your own machine while you build, not for a public website.
What happens on a request
Open http://127.0.0.1:8000/ in the browser. The browser sends GET / to the development server, which hands it to urls.py. Django goes down the list: admin/ doesn't match, the empty path does. So Django calls views.home, and the response rides back. The page shows Hello blog, my first app.
The terminal logs it:
[09/Nov 00:50:11] "GET / HTTP/1.1" 200 25
Status 200, and 25 bytes: the size of the reply, exactly the length of our sentence.
When no URL matches
Ask for /nothing/. Django tries admin/, then the empty path, and nothing matches. No view is called, and Django answers with 404. Because DEBUG is on in the settings, the Not Found page even lists the URL patterns Django tried, which helps while you build.
Not Found: /nothing/
[09/Nov 00:50:11] "GET /nothing/ HTTP/1.1" 404 2420
So for every page you want, you add a path in urls.py.
Common mistakes
- Leaving out the dot in
startproject blogproject ., which wraps everything in one more folder. - Creating the app but not adding it to
INSTALLED_APPS. Django won't load its models. - Writing
views.home()in the path. That calls the function right away; Django needs the function itself. - Using
runserverfor a public site. It's a development server only.
Quick recap
| Command or file | What it does |
|---|---|
uv init --bare, uv add django | project file, virtual environment, Django 6.1.3 |
django-admin startproject blogproject . | manage.py and the project package |
manage.py startapp blog | the blog app folder |
INSTALLED_APPS | joins the app to the project |
views.home + path('', views.home) | a page at the home address |
manage.py check, runserver | checks, then serves on 127.0.0.1:8000 |
Try it yourself
Add a second view called about, give it the path about/, and open it in the browser. Watch the terminal log the request with its status and size.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose
One small project lists two blog posts three times: as a Django view, a Flask route and a FastAPI endpoint. See each shape with its real output, what each framework includes, and a three-question way to choose.
Getting Started with Django: Models, Views, Templates, the ORM and the Admin
A tiny Django menu app with one model, one view, one URL, one template and the admin. What each file does, how one request travels through them, and the real output of a run.
The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built
A tour of a finished Django blog: manage.py, the project package, the blog app with its models, views, templates, forms and admin, a custom command, the REST API and Swagger docs, plus the review points check --deploy found.
How a Request and a Login Flow Through Django: URLconf, ORM, CSRF, Password Hashes and Sessions
Follow the home page from URLconf to SQLite and back (8 queries), then a login: the csrftoken, a 403 without it, the pbkdf2 password hash, the django_session row, the sessionid cookie, and a review finding about who may write posts.
