Skip to content
Learn Netverks

Lesson

Step 17/36 47% through track

static-files

Static files

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

This lesson

This lesson teaches Static files: the syntax, APIs, and habits you need before advancing in Django.

Teams ship Static files on every Django codebase—skipping it leaves gaps in debugging and code reviews.

You will apply Static files 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.

CSS, JavaScript, and images live in static files—separate from templates and user uploads. Django collects them for production with collectstatic.

Development setup

  • App static folder: blog/static/blog/style.css
  • STATIC_URL = '/static/' in settings
  • Load in templates: {% load static %} then <link href="{% static 'blog/style.css' %}">

Production

python manage.py collectstatic copies files to STATIC_ROOT; nginx or whitenoise serves them efficiently. User uploads use MEDIA_URL/MEDIA_ROOT—different from static assets.

Important interview questions and answers

  1. Q: STATIC vs MEDIA?
    A: STATIC is developer assets (CSS/JS); MEDIA is user-uploaded content (avatars, documents).
  2. Q: Why collectstatic?
    A: Production servers serve one consolidated directory—not scattered app folders.
  3. Q: DEBUG=True static serving?
    A: Django dev server serves static when configured; production needs whitenoise or nginx.

Self-check

  1. Where do you put app-specific CSS?
  2. What command prepares static files for production?

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

  • collectstatic when?
  • MEDIA vs STATIC?

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