Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Django
  • Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose
  • Getting Started with Django: Models, Views, Templates, the ORM and the Admin
  • Your First Django Project and App: uv, startproject, startapp and a First View
  • The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built
  • How a Request and a Login Flow Through Django: URLconf, ORM, CSRF, Password Hashes and Sessions
  • Testing a Django Blog with pytest-django: Fixtures, the Test Database and the Client
  • One Blog, Three Frameworks: Routing, Models, Templates and Layout in Django, FastAPI and Flask
  • Building a Blog with an AI Coding Agent: Plan Mode, a Master Prompt and the First Review
  • Handing a Figma Design to an AI Agent: Compare the Files, Then Review the Change
  • Django Models, Migrations and the Admin: From a Post Class to a Real Table
  1. Blog
  2. /
  3. Django
  4. /
  5. Fundamentals

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.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Fundamentals

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.py holds the house rules, like the list of installed apps and the database.
  • urls.py is the front door. Every request that comes in is matched against the list in here. It already has one entry, admin/.
  • wsgi.py and asgi.py are how a production web server talks to the project once it's deployed. We won't touch them now.
  • __init__.py is empty. It makes blogproject a 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
manage.py runs the commands. The blogproject package holds settings.py, the house rules, and urls.py, the front door. The blog app holds models.py, views.py, admin.py, apps.py, tests.py and migrations. INSTALLED_APPS in settings.py joins the app to the project. manage.py runs commands blogproject (project) settings.py: house rules INSTALLED_APPS: 'blog' urls.py: front door wsgi.py, asgi.py for production servers blog (app) models.py, migrations/ views.py admin.py, apps.py tests.py one feature
The project holds the rules and the front door. The app holds one feature. INSTALLED_APPS joins them.

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

GET / goes from the browser to the development server, then urls.py, where admin/ does not match and the empty path does, so views.home runs and returns 200. GET /nothing/ matches no path and gets a 404 without calling any view. Browser GET / urls.py '' matches views.home HttpResponse 200 25 bytes Browser GET /nothing/ urls.py no match 404 Not Found no view is called
One path matches and its view answers. No path matches and Django answers 404 by itself.

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 runserver for a public site. It's a development server only.

Quick recap

Command or fileWhat it does
uv init --bare, uv add djangoproject file, virtual environment, Django 6.1.3
django-admin startproject blogproject .manage.py and the project package
manage.py startapp blogthe blog app folder
INSTALLED_APPSjoins the app to the project
views.home + path('', views.home)a page at the home address
manage.py check, runserverchecks, 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.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Django · 3 of 10

Previous
Getting Started with Django: Models, Views, Templates, the ORM and the Admin
Next post
The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built

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.

On this page

  • A uv project with Django
  • Creating the project
  • Inside blogproject
  • Creating the blog app
  • Telling the project about the app
  • Our first view
  • A URL for the view
  • Running the server
  • What happens on a request
  • When no URL matches
  • Common mistakes
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

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)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.