Skip to content

Ideas for additional labs #25

@tim-schilling

Description

@tim-schilling

Overview

Some ideas for additional labs based on common debugging scenarios Django developers face after completing the tutorial and working on their first projects.


High Value (Almost everyone hits these)

Timezone Issues

  • Naive vs aware datetime comparisons causing silent bugs
  • USE_TZ=True but comparing with datetime.now() instead of timezone.now()
  • Dates filtering incorrectly across timezone boundaries
  • Great for Debug Toolbar since you can inspect the actual SQL datetime values

CSRF Token in AJAX Requests

  • Form works fine, but JavaScript fetch/axios POST fails with 403
  • Teaches browser dev tools Network panel for inspecting headers
  • Common when adding interactivity to Django templates

Template Context Silently Failing

  • Variable typo in template renders as empty string (no error)
  • Missing context variable from view
  • Teaches string_if_invalid setting and how Django's template silence can hide bugs

Migration Conflicts

  • Two developers add migrations, both numbered 0005
  • makemigrations --merge workflow
  • Very common in team environments

Medium Value (Common enough, good teaching moments)

Static Files Not Loading

  • Works in development, breaks in production
  • STATIC_URL vs STATIC_ROOT vs STATICFILES_DIRS confusion
  • collectstatic not run
  • Debug Toolbar can show 404s for static assets

Form Validation Errors Not Displaying

  • form.errors exists but template doesn't render them
  • {{ form.non_field_errors }} forgotten
  • Field-level errors vs form-level errors

Middleware Ordering

  • Authentication middleware after something that requires request.user
  • Session middleware ordering issues
  • Good for understanding the request/response cycle

Model.save() Not Persisting Changes

  • Forgetting to call save() after modifying instance
  • update_fields excluding the field you changed
  • QuerySet methods returning new querysets (immutability confusion)

Lower Priority (More niche but educational)

Email Not Sending in Development

  • EMAIL_BACKEND not set to console backend
  • Good excuse to introduce django-debug-toolbar's mail panel or django-mailer

Logging Configuration

  • Logs not appearing despite logger.error() calls
  • Log level hierarchy confusion
  • Propagation issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions