Django 6.1.3 on SQLite (in-memory): ch11-auth 1. SessionMiddleware lazy access, modified flag, and stores untouched: sql=0 accessed=False modified=False vary=None set_cookie=False read_only: sql=1 accessed=True modified=False vary='Cookie' set_cookie=False modified: sql=3 accessed=True modified=True vary='Cookie' set_cookie=True stores: cached_db_miss_sql=1 cached_db_hit_sql=0 signed_cookie_sql=0 values=['metro', 'metro', 'metro'] 2. AuthenticationMiddleware SimpleLazyObject and HASH_SESSION_KEY login_rotation: session_key_cycled=True csrf_rotated=True anon_data_preserved=True keys=['_auth_user_backend', '_auth_user_hash', '_auth_user_id'] before_access: sql=0 wrapped_is_empty=True has_auser=True after_access: sql=2 wrapped_type=User username='editor' password_change: hash_changed=True old_session_user=AnonymousUser is_authenticated=False session_flushed=True 3. Backends, PermissionDenied short-circuit, and PBKDF2 upgrade django_6_1_default: algorithm='pbkdf2_sha256' iterations=1,500,000 transparent_rehash: authed=True backend='django.contrib.auth.backends.ModelBackend' iterations_before=100,000 iterations_after=1,500,000 permission_denied_short_circuit: result=None backends_called=['deny_backend'] 4. PermissionsMixin _perm_cache staleness and ContentType._cache perm_cache: first_sql=2 repeat_sql=0 before=False repeat=False after_db_grant_same_obj=False fresh_obj=True cached_attrs_on_user = ['_group_perm_cache', '_perm_cache', '_user_perm_cache'] contenttype_cache: cold_sql=1 warm_model_sql=0 warm_id_sql=0 same_obj=True 5. AdminSite registry, dynamic URLs, and admin_view registered_models (8) = ['auth.group', 'auth.user', 'newsroom.beat', 'newsroom.desk', 'newsroom.edition', 'newsroom.reporter', 'newsroom.story', 'subscribers.subscription'] story_admin_urls = ['newsroom_story_changelist', 'newsroom_story_add', 'newsroom_story_history', 'newsroom_story_delete', 'newsroom_story_change'] admin_view: anon_status=302 anon_redirect='/admin/login/?next=/admin/newsroom/story/' staff_status=200 cache_control='max-age=0, no-cache, no-store, must-revalidate, private' 6. ChangeList auto-select_related vs custom callable N+1 default_StoryAdmin (25 stories): sql=5 auto_select_related=['desk', 'reporter', 'edition'] callable_no_select (25 stories): sql=80 auto_select_related=[] (N+1 storm!) callable_list_select_related: sql=5 no_full_result_count_sql=4 filtered_search (?status__exact=published&q=bridge): rows=1 sql=5 7. ModelAdmin._changeform_view atomic POST, inlines, and LogEntry changeform_post: status=302 redirect='/admin/newsroom/story/' sql=26 corrections_after=3 atomic_write_order = ['BEGIN', 'UPDATE newsroom_story', 'INSERT newsroom_correction', 'INSERT django_admin_log'] log_entry: action_flag=2 (CHANGE) object_repr='Bridge bond clears council on 6-3 vote' change_message_json = [{"changed": {"fields": ["Headline"]}}, {"added": {"name": "correction", "object": "Correction #4 on bridge-bond-passes"}}] change_message_text = 'Changed Headline. Added correction “Correction #4 on bridge-bond-passes”.'