What we'll build
A simple notes list: add entries, see the list, edit through the admin panel. An evening's work that shows you how the framework fits together.
Step 1. Environment and installation
python -m venv .venv
source .venv/bin/activate
pip install django
Step 2. Creating the project
django-admin startproject notes .
The trailing dot matters: without it you get a redundant nested folder.
You'll get a management script and a settings folder.
Step 3. Creating an app
python manage.py startapp diary
A Django project consists of apps — separate parts with their own logic. That's the convention even for a small project.
Register the app in the project settings by adding it to the installed apps list.
Step 4. The model
A model describes what will be stored in the database. In the app's models file, describe a note: title, body, creation date.
Then two commands:
python manage.py makemigrations
python manage.py migrate
The first writes a description of the database changes, the second applies them. Understanding the difference matters: the first is a plan, the second is execution.
Step 5. The admin panel
Register the model in the admin file and create a user:
python manage.py createsuperuser
Run it:
python manage.py runserver
Visit the admin path and you can already add and edit records. This is what draws many people to Django: a full admin panel without a line of interface code.
Step 6. A view and a route
Write a view that fetches the list of notes and passes it to a template, add a route in the app's URL list, and connect that to the project's routes.
The important part is the scheme: a request arrives, the framework matches the address to a view, the view fetches data, passes it to a template, and a response goes back.
Step 7. The template
Create a templates folder inside the app and a page that loops over the notes and prints them.
Run it and check that entries added through the admin appear on the page.
What you learned in an evening
The scheme behind any web framework: route, handler, data, template, response. It's the same in Django, Flask and nearly everywhere else — only the syntax changes.
What to do next
Add a form to create a note on the page itself, then editing and deletion. Then deploy the project so it opens behind a link.
That will be a portfolio project — provided you finish it and write the README.
Хватит читать — пора делать
На CohortX можно найти команду под пет-проект и получить тот самый опыт, о котором спрашивают на собеседовании.
Похожие статьи
- FastAPI: your first service in an eveningWhat a service for programs is, how to write your first one in an evening, and why automatic documentation saves time.
- FastAPI: первый сервис за вечерЧто такое сервис для программ, как написать первый за вечер и почему автоматическая документация экономит время.
- Django для начинающих: первый проект по шагамОт установки до работающего списка записей с панелью управления — что делать по шагам и что означает каждый шаг.