Django-the Practical Guide ((hot)): Python

Add 'blog' to INSTALLED_APPS in settings.py .

@admin.register(Post) class PostAdmin(admin.ModelAdmin): list_display = ('title', 'created_at') search_fields = ('title',) python django-the practical guide

from django.urls import path from . import views Add 'blog' to INSTALLED_APPS in settings

This is a basic example of how to structure a Django project and create a simple app. 'created_at') search_fields = ('title'

from django.db import models

| Pitfall | Solution | |---------|----------| | Forgetting to run migrate after makemigrations | Always run both | | Modifying models without migrations | Run makemigrations | | Hardcoding secrets in settings | Use python-decouple or env vars | | Serving static files in production with Django | Use WhiteNoise or CDN | | CSRF token missing in POST forms | Add % csrf_token % inside <form> |