DRF ModelSerializer ignores a posted field that isn't in Meta.fields: 'psycopg.errors.NotNullViolation: null value in column "project_id" of relation "api_task" violates not-null constraint'
Fix: add the field to the serializer's Meta.fields (e.g. fields = ['id', 'project', 'title', ...]), or set it server-side with serializer.save(project=project) in perform_create.
Cause: a ModelSerializer only reads the keys listed in Meta.fields; anything else in the request body is dropped silently, with no validation error. The model then saves with project_id NULL and Postgres rejects it, so a client error surfaces as an IntegrityError/500 instead of a 400.
Observed with DRF 3.15.2, Django 5.1 and psycopg 3.2: a test POSTing {'project': project.id, 'title': ...} to a Task endpoint failed with the NotNullViolation above until 'project' was added to TaskSerializer.Meta.fields. If the client should not choose the parent, keep it out of fields and pass it to save() from the URL or the request user instead.