Opened 58 minutes ago
#37195 new New feature
Add --exclude-system option to dumpdata to skip Django-managed models
| Reported by: | abdullah | Owned by: | |
|---|---|---|---|
| Component: | Core (Management commands) | Version: | 6.0 |
| Severity: | Normal | Keywords: | |
| Cc: | abdullah | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Currently, when using dumpdata to export application data, users often need to manually exclude Django-managed models such as content types, permissions, admin logs, and sessions.
For example:
python manage.py dumpdata \ --exclude contenttypes \ --exclude auth.Permission \ --exclude admin.LogEntry \ --exclude sessions.Session
This is repetitive and easy to get wrong, especially across projects with different INSTALLED_APPS.
Some of this data is environment-specific or regenerated by Django through migrations and post-migrate handlers. Including it in fixtures can cause conflicts or unwanted records when loading data into another database.
I would like to propose adding a convenience option to dumpdata, for example:
python manage.py dumpdata --exclude-system
or possibly:
python manage.py dumpdata --exclude-internal
This option would exclude a predefined set of Django-managed/internal models from serialization.
Possible candidates could include:
- contenttypes.ContentType - auth.Permission - admin.LogEntry - sessions.Session
The exact list and option name can be discussed.
This would be backwards-compatible because the behavior would only apply when the option is explicitly provided. Existing dumpdata behavior would remain unchanged.