# TypeError: Object of type 'MyModel' is not JSON serializable

- **ID:** `python/django-json-response-serialization`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Trying to return a Django model instance directly in JsonResponse without serializing to dict.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Use model_to_dict: from django.forms.models import model_to_dict; return JsonResponse(model_to_dict(instance))
   ```
2. **** (90% success)
   ```
   Create a custom serializer: return JsonResponse({'id': instance.id, 'name': instance.name})
   ```

## Dead Ends

- **** — Produces a string representation, not useful JSON data. (80% fail)
- **** — Still fails because model instance is not JSON serializable. (90% fail)
