Django for Beginners

Models, views, auth, DRF 20h

Take your Python skills to the web by building full Django apps with models, templates, authentication, and simple REST APIs using Django REST Framework (DRF). You will move from an empty virtual environment to a working, database-backed site that users can sign into and interact with, plus a small API that exposes your data.

Start this training
Self-paced. Work through each module at your own speed.
Who this is for

Developers who already know basic Python and front-end fundamentals and want to build real full-stack web applications. If you have written scripts or small tools and now want to ship something people can log into and use, this is the next step.

Prerequisites

Comfort with Python basics (functions, modules, virtual environments) and HTML/CSS. JavaScript experience is helpful but not required. You should be able to run Python commands from a terminal and install packages with pip.

By the end you will be able to:

5 outcomes
  • Set up Django projects with virtual environments and reusable apps, and understand where settings, URLs, templates, and static files live in the project.
  • Design models, run migrations, and use the Django admin effectively to create, edit, and inspect data without writing raw SQL.
  • Build views, templates, and forms for full CRUD workflows so users can create, update, and delete records through the browser.
  • Implement user registration, login, logout, and basic permissions so different users see only the data they are allowed to see.
  • Expose core data via simple REST APIs using Django REST Framework, and test those APIs using the browsable DRF interface or command-line tools.

Training highlights

4 key themes
  • Django project/app structure, settings, URL routing, and the request/response cycle from browser to view and back.
  • Models, migrations, and the Django admin for quick CRUD operations during development and early prototyping.
  • Views, templates, and form handling for real user flows like registration, listing items, and editing records.
  • Authentication, login-required views, and DRF-powered JSON endpoints that make your project feel like a modern web app.
Django for Beginners

Syllabus

4 sections
Week 1

Environment setup, creating a new Django project and app, understanding URL routing, and defining your first models and migrations. You will explore the Django admin and use it to add and edit sample data.

Week 2

Views and templates, static files, and CRUD forms for your core model. You will build user registration, login, and logout, and use messages or flash alerts to confirm actions.

Week 3

Django REST Framework basics: serializers, API views, and simple JSON endpoints for your app’s core data. You will test your API and understand how it connects to your models.

Capstone Project

Ship a full CRUD Django app (such as a task tracker, notes app, or simple portfolio) with user authentication and a DRF-powered API that exposes at least part of your data.

Training plan

7 modules

Follow these modules step by step. Each one included concrete tasks so you actually learn and ship something real. You could have treated each module as one focused work session or spread the steps across several days.

Module 1: Setup and First Django Project

  • Create and activate a Python virtual environment (for example, using python -m venv .venv and source .venv/bin/activate or the Windows equivalent). Verify that your shell shows the environment name.
  • Install Django with pip install django and use django-admin startproject to create a new project folder. Run python manage.py runserver and confirm that the default Django welcome page appears.
  • Create your first app (for example, 'core' or 'tasks') using python manage.py startapp and add it to INSTALLED_APPS in settings.py so Django knows about it.
  • Open urls.py and wire a simple view function that returns an HttpResponse. Confirm in the browser that visiting the path shows your custom message instead of the default page.
  • Create a requirements.txt file (pip freeze > requirements.txt) so you can easily reinstall dependencies later or on another machine.
  • Explore the project structure (settings.py, urls.py, wsgi/asgi.py) and write a few notes for yourself describing what each file does.

Module 2: Models, Migrations, and Admin

  • Define a simple model (such as Task, Note, or Post) with fields like title, description, created_at, and updated_at. Add __str__ to return a helpful label.
  • Run python manage.py makemigrations and python manage.py migrate to create the database tables. Confirm that your new app’s migrations appear in the output.
  • Create a superuser account with python manage.py createsuperuser and log into the Django admin at /admin. Add a few sample records through the admin UI.
  • Register your model with the admin, and customize list_display and search_fields so the list page shows key fields and allows quick searching.
  • Experiment with optional fields (blank=True, null=True) and choices, then inspect how they appear in the admin interface.
  • Use the Django shell (python manage.py shell) to query your model with the ORM and print results, reinforcing how Django talks to the database.

Module 3: Views, URLs, and Templates

  • Create function-based views for listing all objects and showing a single detail page. Use Django’s ORM to query your model and pass the data into the template context.
  • Add URL patterns in your app’s urls.py and include them from the project’s main urls.py using include(). Confirm that both the list and detail pages work.
  • Create base.html with a shared header, navigation, and footer, then build list and detail templates that extend this base and render the model data.
  • Set up static files (CSS and images), configure STATIC_URL and STATICFILES_DIRS, and confirm that your templates load a stylesheet with {% load static %} and <link> tags.
  • Use the Django template language to loop over querysets and to conditionally show content based on whether the user is authenticated.
  • Implement a simple search form on the list view using GET parameters and filter the queryset based on the search term.

Module 4: Forms, CRUD, and Messages

  • Create a ModelForm or Form class for your main model, and build create and edit views that display the form, validate input, and save data to the database.
  • Add delete functionality with a confirmation page so users can safely remove records. Use Django’s messages framework to show success notifications.
  • Use redirect after successful form submissions (the PRG pattern) to avoid duplicate posts when users refresh the page.
  • Add built-in validation rules (such as max_length and blank=False) and create at least one custom clean_ method to enforce a rule that is specific to your domain.
  • Use crispy-forms or basic Bootstrap classes to improve the visual layout of your forms so they are easier to use.
  • Create a 'recent items' section on the home page that shows the latest few records created or updated via your forms.

Module 5: Authentication and Permissions

  • Implement user signup, login, and logout using Django’s built-in auth views or your own custom views and templates. Make sure the navigation updates based on whether the user is authenticated.
  • Use the login_required decorator (or LoginRequiredMixin) to protect views so only logged-in users can access certain pages.
  • Associate created records with request.user so each object has an owner. Filter querysets so users see only their own records on certain pages.
  • Add basic permissions in views to ensure that only owners (or staff) can edit or delete specific records.
  • Use the messages framework to greet users after login and to confirm actions like changing a password or updating a profile.
  • Create a simple profile page that shows the current user’s information and a list of objects they own.

Module 6: Intro to Django REST Framework

  • Install Django REST Framework (pip install djangorestframework), add it to INSTALLED_APPS, and configure a basic REST_FRAMEWORK setting if needed.
  • Create a serializer for your main model that defines the fields to expose as JSON. Test the serializer in a Django shell to see the output.
  • Build a simple APIView, generic view, or ViewSet that lists objects and allows creating new ones via POST. Wire it up in urls.py under an /api/ path.
  • Open the API endpoint in your browser to use DRF’s browsable API. Try making test requests from the UI or from a tool like curl or HTTPie to confirm that JSON data is returned and accepted.
  • Restrict API access so that only authenticated users can create or modify data, while read-only endpoints remain public if appropriate.
  • Add simple filtering (such as filtering by the current user) so each client only sees the records they are allowed to see.

Practice & Assessment: Small Production-Ready App

  • Build a small CRUD app such as a task manager, bookmarks app, or notes app. The app should allow creating, updating, and deleting items through forms.
  • Implement user-specific data so each authenticated user sees only their own records. Test with two different user accounts.
  • Expose a read-only API endpoint for your main model using DRF. Confirm that the endpoint returns the correct JSON and is filtered by user if applicable.
  • Document the steps required to set up the project from scratch (clone, install, migrate, createsuperuser, runserver) so you can deploy or share the app later.
  • Add a small 'admin checklist' for yourself that includes checking DEBUG settings, configuring ALLOWED_HOSTS, and setting up a production database.
  • Reflect on what you built: write a short summary of what the app does, who it is for, and which parts of Django you used to support those features.