# django.db.utils.IntegrityError: NOT NULL constraint failed: app_model.foreign_key_id

- **ID:** `python/django-foreign-key-null`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to save a model instance without a required foreign key value.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Ensure the related object is created first and assign it: obj.foreign_key = related_obj; obj.save()
   ```

## Dead Ends

- **** — 0 typically doesn't exist, causing integrity errors or wrong references. (70% fail)
- **** — Breaks data integrity and business logic. (50% fail)
