Django application and library for importing and exporting data with admin integration.

Overview

django-import-export

Build status on Travis-CI https://coveralls.io/repos/github/django-import-export/django-import-export/badge.svg?branch=master Current version on PyPi Documentation

PyPI - Python Version

PyPI - Django Version

django-import-export is a Django application and library for importing and exporting data with included admin integration.

Features:

  • support multiple formats (Excel, CSV, JSON, ... and everything else that tablib support)
  • admin integration for importing
  • preview import changes
  • admin integration for exporting
  • export data respecting admin filters

docs/_static/images/django-import-export-change.png

Example app

To run the demo app:

cd tests
./manage.py makemigrations
./manage.py migrate
./manage.py createsuperuser
./manage.py loaddata category book
./manage.py runserver

Contribute

If you'd like to contribute, simply fork the repository, commit your changes to the develop branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS.

As most projects, we try to follow PEP8 as closely as possible. Please bear in mind that most pull requests will be rejected without proper unit testing.

Issues
  • Better surfacing of validation errors in UI / optional model instance validation

    Better surfacing of validation errors in UI / optional model instance validation

    Hi @bmihelac,

    Related issues:

    • #64
    • #176
    • #415
    • #601

    Here's where I've got to so far. I thought it would be good to get some feedback before getting stuck into writing new tests, but the current ones are passing, so at least nothing is broken :)

    When enabled, instance.full_clean() is called for each row, and any resulting validation errors surface themselves in the preview table like so:

    screenshot 2018-11-02 at 15 35 37

    The errors are hidden visually at first, then become visible when you hover over a row's first column, in such a way that it doesn't hide any of the values for the current row. It's pretty crude, but it's a starting point. Some examples:

    screenshot 2018-11-02 at 15 35 42 screenshot 2018-11-02 at 15 35 53

    Anyone wanting to give this a whirl for themselves should be able to install from git using:

    pip install git+https://github.com/ababic/[email protected]ing

    Any/all feedback welcome :)

    opened by ababic 43
  • question:UnicodeDecodeError at /admin/blog/author/import/

    question:UnicodeDecodeError at /admin/blog/author/import/

    Sir,thanks a lot to develop this great repository. I have little problem to solve , as below the code:

    #in models.py
    class Author(models.Model):
        author = models.CharField('作者', max_length=50)
        title = models.CharField('标题', max_length=150)
        qualification = models.ForeignKey(Qualification)
        mark = models.ManyToManyField(Mark)
        blog = models.TextField('博客内容')
        time = models.DateField('写作日期')
    
        def __unicode__(self):
            return unicode(self.author)
    
        class Meta:
            ordering = ['time']
    
    #in admin.py
    class AuthorAdmin(ImportExportModelAdmin, admin.ModelAdmin):
        search_fields = ('author', 'title', 'mark', 'blog')
        list_display = ('author', 'title', 'time')
    

    When I export the data, 1 but the csv file appear to be the retortion, 2 when I modified the second row author data and import,

    3 it cause the error, 4

    how I it be smoothly modified and import?thanks. Allenlee

    opened by hebijiandai 31
  • when import csv file ,KeyError: u'id' occured

    when import csv file ,KeyError: u'id' occured

    i try to import some data form csv file, but errors occurred as follows:

    Errors Line number: 1 - u'id' Traceback (most recent call last): File "/home/zhijiasun/.virtualenvs/tutorial/local/lib/python2.7/site-packages/import_export/resources.py", line 317, in import_data instance, new = self.get_or_init_instance(instance_loader, row) File "/home/zhijiasun/.virtualenvs/tutorial/local/lib/python2.7/site-packages/import_export/resources.py", line 149, in get_or_init_instance instance = self.get_instance(instance_loader, row) KeyError: u'id'

    I just modify the data of the csv file which exported by the app and then try to import it. But error happed.

    stale 
    opened by zhijiasun 28
  • CLI import (reprise)

    CLI import (reprise)

    This is a continuation of @int-ua's work in #725, addressing #332. I've resolved conflicts, tweaked the documentation and tests, but otherwise kept it identical.

    I need this feature too, so I'd like to get it merged sooner rather than later. However, there are other tweaks I'd like to make, including:

    • Better documentation, including its own page in the Reference
    • Format options:
      • arg to list available formats, calling into base_formats rather than being hardcoded
      • arg to specify format to use rather than guessing
    • Detect whether supplied class is a Resource or Model rather than needing to specify
    • raise_errors currently defaults to True if dry_run is False - is this the right thing to do?
    • Option to supply kwargs to the Resource constructor (which I need for my own project)
    • Hey, export would be nice too

    ... but let's start with this, and if I get time for those tweaks I'll make them in a separate PR.

    enhancement needs update 
    opened by yozlet 27
  • Added ExportViewMixin

    Added ExportViewMixin

    Created a mixin view to export without admin interface.

    I think it would be a really great thing if we have a generic class based views for this application.

    I tested this patch with a ListView & django_filters.views.FilterView. The 2nd is really useful to replace the AdminFilters

    needs update 
    opened by ZuluPro 23
  • Many to many fields and admin upload

    Many to many fields and admin upload

    Do many to many fields work via admin imports? I keep getting something like this: ValueError('"<Accession: >" needs to have a value for field "accession" before this many-to-many relationship can be used.',)

    It doesn't seem like it can if it's displaying the data to import before importing, as there's no way to get the primary key for the row since it doesn't have one yet?

    Thanks,

    Dean

    opened by lfarrell 23
  • CLI import_file command

    CLI import_file command

    #332

    enhancement needs update 
    opened by int-ua 19
  • 1.8 compatibility

    1.8 compatibility

      File "/Users/syabro/.envs/homeowners/lib/python2.7/site-packages/import_export/resources.py", line 16, in <module>
        from django.db.models.related import RelatedObject
    ImportError: No module named related
    

    because

    The django.db.models.related module has been removed and the Field.related attribute will be removed in Django 2.0.

    https://docs.djangoproject.com/en/dev/releases/1.8/#model-field-related

    bug 
    opened by syabro 19
  • Use Github secret in CI script instead of hard-coded password

    Use Github secret in CI script instead of hard-coded password

    Problem

    A minor improvement to the CI script.

    The CI script was using a hard-coded password which is not ideal. Best practice is to use a secret defined in Github.

    Solution

    The CI script now uses a Github secret instead of a hard-coded password.

    Acceptance Criteria

    Verified that the CI process ran ok, meaning the change is valid.

    opened by matthewhegarty 1
  • Added python3.10 to tox environment list

    Added python3.10 to tox environment list

    Problem

    Now that python 3.10 is available, I have added it to the list of supported python releases.

    Whilst testing this, I noticed tox failures for >= 3.9 only, because support for pytz was dropped in that release. However, since pytz is still a dependency for Django, I added it to the import list in test.txt, since it is required for test_widgets.py.

    Solution

    • Updated files to reference python 3.10.

    Acceptance Criteria

    Ran full tox run through locally.

    opened by matthewhegarty 6
  • added skip_html_diff parameter

    added skip_html_diff parameter

    Problem

    This is a performance improvement when importing large numbers of rows.

    If one is not using the Admin site, then there is no need for the as_html() call to be made for each row.

    Solution

    This PR adds a new meta attribute skip_html_diff which is used to skip the as_html() call if enabled.

    I've also tested and documented the performance differences.

    I also pulled in some of the documentation changes from #1274, including instructions on running performance tests using the supplied script.

    Acceptance Criteria

    I have added a new unit test and manually tested imports. Obviously the HTML report doesn't render on the confirmation page in the admin site if this is enabled, but import still works via the Admin site.

    opened by matthewhegarty 1
  • yaml export crashes for objects with decimal values

    yaml export crashes for objects with decimal values

    Describe the bug

    Export is broken when one tries to export an object containing a DecimalField (e.g. Book).

    The error is:

    RepresenterError at /admin/core/book/export/
    ('cannot represent an object', Decimal('1.00'))
    

    To Reproduce Steps to reproduce the behavior:

    1. Login to the Admin site
    2. Create a book with a 'price' value
    3. Export books (select 'yaml' format)
    4. The crash should occur.

    Versions (please complete the following information):

    • Django Import Export: 2.5.0
    • Python 3.9
    • Django 3.2

    Expected behavior

    Yaml export should work correctly. Other exports work correctly.

    Stack trace

    Exception Type:	RepresenterError
    Exception Value:	
    ('cannot represent an object', Decimal('1.00'))
    Exception Location:	/home/matthew/.virtualenvs/django-import-export/lib/python3.9/site-packages/yaml/representer.py, line 231, in represent_undefined
    
    bug 
    opened by matthewhegarty 1
  • Documentation of properties required for row_result

    Documentation of properties required for row_result

    Describe the bug

    The row_result object which is generated by each row import has undocumented properties. This was raised here.

    ** Solution **

    I guess attributes should be documented here

    To Reproduce

    Versions (please complete the following information):

    • Django Import Export: 2.5.0
    • Python (all)
    • Django (all
    docs good first time issue 
    opened by matthewhegarty 0
  • Import files in app with two or more containers provisioned

    Import files in app with two or more containers provisioned

    Describe the bug Currently, when we want to import a file, in the first screen django-import-export send that file to save it in the server's temp directory and return a form where there is the file's data to user confirm if they want to import it. After the user's confirmation, the library uses the file saved on the temp directory and import its data.

    When an app has two or more containers provisioned, that approach doesn't work because it's impossible to ensure the same container where the file has been created will be the same container that will receive the request to import that file.

    To Reproduce Steps to reproduce the behavior:

    1. Install django-import-export in some Django app
    2. Configure some Admin menu to use the import function
    3. Run that app with two or more containers provisioned
    4. Import file through Admin menu
    5. It'll show an error

    Versions (please complete the following information):

    • Django Import Export: 2.5.0
    • Python: 3.7
    • Django: 2.2.24

    Expected behavior The file should be imported regardless of how many containers are running

    Screenshots image

    Additional context I've created this pull request with the solution to solve that problem.

    bug 
    opened by flaviosilva-iteris 5
  • Import file without show screen to confirm

    Import file without show screen to confirm

    Problem

    Currently, when we want to import a file, in the first screen django-import-export send that file to save it in the server's temp directory and return a form where there is the file's data to user confirm if they want to import it. After the user's confirmation, the library uses the file saved on the temp directory and import its data.

    When an app has two or more containers provisioned, that approach doesn't work because it's impossible to ensure the same container where the file has been created will be the same container that will receive the request to import that file.

    Solution

    Implemented a new feature that if the environment variable "PROCESS_WITHOUT_SHOW_CONFIRM_FORM" is true, the file will be imported directly without showing the screen to confirm data inside of that. This way, it's possible to ensure the same file sent will be imported into the database.

    Acceptance Criteria

    If the environment variable "PROCESS_WITHOUT_SHOW_CONFIRM_FORM" is false, the library must work as it works nowadays. If true, the confirmation form mustn't show and the file has to be imported.

    Have you written tests? Yes, I have (tests/core/tests/test_admin_integration.py, test_import_without_show_confirm_form) Have you included screenshots of your changes if applicable? No, It's not applicable. Did you document your changes? Yes,

    opened by flaviosilva-iteris 5
  • How about support dark mode style when importing from admin pages

    How about support dark mode style when importing from admin pages

    Describe the bug This is a suggestion rather than a bug, so everything works fine, except the design: When using dark mode, the import confirmation view does not display properly

    To Reproduce Steps to reproduce the behavior:

    1. Apply admin using ImportMixin, ImportExportMixin or ImportExportModelAdmin
    2. Click the 'import' button from the admin view from step 1
    3. Select importing file, and format of the file
    4. After clicking the 'submit' button, you can see the import confirmation view
    5. When using dark mode, and from the view in step 4, you hardly see the import details.

    Versions (please complete the following information):

    • Django Import Export: 2.5.0
    • Python 3.9.6
    • Django 3.2.5

    Expected behavior The import details should see easily when using dark mode

    Screenshots 스크린샷 2021-08-25 오전 4 25 48

    Additional context Please refer: https://developer.mozilla.org/docs/Web/CSS/@media/prefers-color-scheme

    bug 
    opened by clichedmoog 2
  • Tmp storage encoding changes

    Tmp storage encoding changes

    Temporary PR for discussion about encoding handling.

    opened by manelclos 1
  • Single export format -> skip

    Single export format -> skip "choose export format" page

    This is a improvement request.

    Once I define in my admin class a formats field with a single format it doesn't make sense to ask user which format he wants to export data to. The page then contains a selectbox with only option so no need to ask user if there is no choice.

    bug 
    opened by im-n1 0
Releases(2.6.1)
Django admin CKEditor integration.

Django CKEditor NOTICE: django-ckeditor 5 has backward incompatible code moves against 4.5.1. File upload support has been moved to ckeditor_uploader.

null 2k Nov 25, 2021
Django admin CKEditor integration.

Django CKEditor NOTICE: django-ckeditor 5 has backward incompatible code moves against 4.5.1. File upload support has been moved to ckeditor_uploader.

null 2k Dec 2, 2021
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

lhy 96 Nov 28, 2021
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 675 Nov 28, 2021
Add Chart.js visualizations to your Django admin using a mixin class

django-admincharts Add Chart.js visualizations to your Django admin using a mixin class. Example from django.contrib import admin from .models import

Dropseed 9 Oct 18, 2021
📝 Sticky Notes in Django admin

django-admin-sticky-notes Share notes between superusers. Installation Install via pip: pip install django_admin_sticky_notes Put django_admin_sticky_

Dariusz Choruży 7 Oct 6, 2021
mirage ~ ♪ extended django admin or manage.py command.

mirage ~ ♪ extended django admin or manage.py command. ⬇️ Installation Installing Mirage with Pipenv is recommended. pipenv install -d mirage-django-l

Shota Shimazu 6 Sep 14, 2021
Super simple bar charts for django admin list views visualizing the number of objects based on date_hierarchy using Chart.js.

Super simple bar charts for django admin list views visualizing the number of objects based on date_hierarchy using Chart.js.

foorilla LLC 2 Nov 21, 2021
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 160 Oct 31, 2021
django Filer is a file management application for django that makes handling of files and images a breeze.

django Filer is a file management application for django that makes handling of files and images a breeze.

django CMS Association 1.5k Nov 28, 2021
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.4k Dec 3, 2021
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 866 Dec 2, 2021
Plug and play continuous integration with django and jenkins

django-jenkins Plug and play continuous integration with Django and Jenkins Installation From PyPI: $ pip install django-jenkins Or by downloading th

Mikhail Podgurskiy 935 Nov 17, 2021
A simple app that provides django integration for RQ (Redis Queue)

Django-RQ Django integration with RQ, a Redis based Python queuing library. Django-RQ is a simple app that allows you to configure your queues in djan

RQ 1.5k Dec 1, 2021
Bootstrap 3 integration with Django.

django-bootstrap3 Bootstrap 3 integration for Django. Goal The goal of this project is to seamlessly blend Django and Bootstrap 3. Want to use Bootstr

Zostera B.V. 2.3k Nov 27, 2021
Bootstrap 4 integration with Django.

django-bootstrap 4 Bootstrap 4 integration for Django. Goal The goal of this project is to seamlessly blend Django and Bootstrap 4. Requirements Pytho

Zostera B.V. 936 Nov 18, 2021
A django integration for huey task queue that supports multi queue management

django-huey This package is an extension of huey contrib djhuey package that allows users to manage multiple queues. Installation Using pip package ma

GAIA Software 25 Nov 8, 2021
TinyMCE integration for Django

django-tinymce django-tinymce is a Django application that contains a widget to render a form field as a TinyMCE editor. Quickstart Install django-tin

Jazzband 1.1k Dec 1, 2021
Bootstrap 3 integration with Django.

django-bootstrap3 Bootstrap 3 integration for Django. Goal The goal of this project is to seamlessly blend Django and Bootstrap 3. Want to use Bootstr

Zostera B.V. 2.3k Nov 23, 2021