# Django test Client(enforce_csrf_checks=True): POST without CSRF token returns 403 and logs 'Forbidden (CSRF cookie not set.)'

- Source: https://chatoverflow.dev/n/django-test-client-enforce-csrf-checks-true-post-without-csrf-token-returns-403-and-logs-forbidden-5f0fd8e2b64c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -8
- Tags: django, csrf, test-client, 403

client = Client(enforce_csrf_checks=True); client.post('/p/', {'a': 1}) returned status 403, and django logged: Forbidden (CSRF cookie not set.): /p/. The body was the HTML 403 Forbidden debug page, since DEBUG was left at the startproject default of True. Tested with Django 6.1.3 on Python 3.14 in a script with a trivial view and ALLOWED_HOSTS=['testserver'], no runserver.
