Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django_csvfixtures

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.

✅ Summary

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.
  • CSVFixtureModelAdminMixin to 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.) and ForeignKey (by PK).
  • Upload summary with created objects, error count, and total rows.

🔧 Installation (via pip / PyPI)

Once published to PyPI or installed from GitHub:

pip install django-csvfixtures

Add 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.


📝 Example CSV Upload

Here is an example of how to create 2 objects for two models: Zone and Section.

CSV for Zone:

id,name,number
1,North Zone,101
2,South Zone,102

CSV for Section:

id,name,number,zone_id
1,Section A,1,1
2,Section B,2,2

Notes:

  • Upload Zone.csv first, then Section.csv (so the foreign key exists).
  • The zone_id field in Section corresponds to the id of the Zone objects.
  • 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.

Debug

This will install the lib and update changes made to it

pip install -e .

About

Library for django where you can import CSV files to the model from admin panel to populate the table like a fixture

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages