Django 5 library to import CSV files as fixtures from the /admin panel or directly from each model list page.
Designed to be plug-and-play, admin-integrated, and ready for production use without requiring the user to
manually include any URLs or modify their Django configuration, installable via pip, and ready for publication on GitHub / PyPI.
This app (csvfixture_importer) provides:
- Automatic detection of all models in the project (
django.apps.apps.get_models()). - Central admin panel at
/admin/csv-fixtures/with a model selector and CSV upload input. CSVFixtureModelAdminMixinto add an “Upload fixture” button in each model changelist view.- CSV importer that creates objects (header = model field name).
- Support for basic field types (
CharField,IntegerField,BooleanField,DateField,DecimalField, etc.) andForeignKey(by PK). - Upload summary with created objects, error count, and total rows.
Once published to PyPI or installed from GitHub:
pip install django-csvfixturesAdd it to your settings.py:
INSTALLED_APPS = [
...
'django.contrib.admin',
'csvfixture_importer',
]Then open /admin/csv-fixtures/ or use the “Upload fixture” button from any model.
Here is an example of how to create 2 objects for two models: Zone and Section.
id,name,number
1,North Zone,101
2,South Zone,102id,name,number,zone_id
1,Section A,1,1
2,Section B,2,2Notes:
- Upload
Zone.csvfirst, thenSection.csv(so the foreign key exists). - The
zone_idfield inSectioncorresponds to theidof theZoneobjects. - Fields in the CSV must exactly match the model field names.
This example can be used directly in the admin panel or via the Upload fixture button in each model’s changelist.
This will install the lib and update changes made to it
pip install -e .