Skip to content
Learn Netverks

Lesson

Step 11/36 31% through track

modules-venv

Modules and virtual environments

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Modules and virtual environments: the syntax, APIs, and habits you need before advancing in Django.

Teams ship Modules and virtual environments on every Django codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Modules and virtual environments in contexts like: SaaS dashboards, CMS-style products, internal tools, and APIs paired with React or mobile clients.

Write Python 3 in the editor and click Run on server—the dev runner executes your script; Django framework lessons also use local startproject for full MVT (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

Django projects are Python packages. You import apps with dotted paths, configure INSTALLED_APPS, and isolate dependencies in a virtual environment.

Imports in Django

from django.shortcuts import render, get_object_or_404
from blog.models import Article

Avoid circular imports—keep models lean, import views only where needed, use lazy references ("app.Model" strings) for ForeignKey when necessary.

Virtual environment workflow

  1. python -m venv .venv
  2. Activate: source .venv/bin/activate (macOS/Linux)
  3. pip install django
  4. django-admin startproject mysite

Commit requirements.txt; never commit the .venv folder itself.

Important interview questions and answers

  1. Q: What is INSTALLED_APPS?
    A: List of Django apps whose models, templates, and static files are loaded—includes django.contrib.admin, your apps, and third-party packages.
  2. Q: requirements.txt vs Pipfile?
    A: Both pin dependencies; teams pick one standard—reproducible installs matter more than the tool.
  3. Q: Circular import fix?
    A: Move shared code to a third module, use string model references, or import inside functions.

Self-check

  1. Why activate a venv before pip install django?
  2. What does from blog.models import Article require in settings?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • venv per project?
  • pip freeze why?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump