0

I'm trying to import data into a model through django admin using dajngo-import-export library, though I'm facing "Improperly Configured" error. This is the error message:

ImproperlyConfigured at /admin/pages/quote/import/
No exception message supplied
Request Method: POST
Request URL:    http://127.0.0.1:8000/admin/pages/quote/import/
Django Version: 3.0
Exception Type: ImproperlyConfigured
Exception Location: C:\Users\Dell\.virtualenvs\read_bus-UfMQ3ck8\lib\site-packages\import_export\resources.py in import_data, line 737
Python Executable:  C:\Users\Dell\.virtualenvs\read_bus-UfMQ3ck8\Scripts\python.exe
Python Version: 3.7.3
Python Path:    
['C:\\Users\\Dell\\Downloads\\read_bus',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\Scripts\\python37.zip',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\DLLs',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\Scripts',
 'c:\\users\\dell\\anaconda3\\Lib',
 'c:\\users\\dell\\anaconda3\\DLLs',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages',
 'C:\\Users\\Dell\\Downloads\\read_bus',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',
 'C:\\Users\\Dell\\.virtualenvs\\read_bus-UfMQ3ck8\\lib\\site-packages\\odf',]

I'm following the documentation as mentioned here.

This is the admin.py file:

class QuoteResource(resources.ModelResource):

    class Meta:
        model =Quote
        import_id_fields=('quote',)
        fields = ('quote','book','author',)

class QuoteAdmin(ImportExportModelAdmin):
    list_display=('quote','book','author')
    resource_class =QuoteResource

admin.site.register(Quote,QuoteAdmin)

I've tried with and without 'QuoteResource', without success.

I'm successfully able to export the data from admin. But facing challenge during import. Snip of admin during import: enter image description here

Following is one of the various ways in which I tried to import data:

enter image description here

Does it has somthing to do with the django settings or the csv data format?

Let me if you need any more information.

4
  • 1
    Your error comes from import export trying to use database transactions but transactions not being supported. What database are you using? github.com/django-import-export/django-import-export/blob/… Commented Aug 19, 2020 at 20:03
  • I'm using MySQL database... Commented Aug 20, 2020 at 4:41
  • 1
    Well it doesn't look like it supports transactions. Add the setting & make it false; IMPORT_EXPORT_USE_TRANSACTIONS. You can see that here; github.com/django-import-export/django-import-export/blob/… Commented Aug 20, 2020 at 8:59
  • Great!! It worked. Thanks man @markwalker Commented Aug 20, 2020 at 18:17

1 Answer 1

2

Your error comes from import export trying to use database transactions but transactions not being supported. So this is an issue with your database.

The section of code from django-import-export can be seen here: https://github.com/django-import-export/django-import-export/blob/master/import_export/resources.py#L737

To disable transactions, add the setting & make it false; IMPORT_EXPORT_USE_TRANSACTIONS.

You can see that here; https://github.com/django-import-export/django-import-export/blob/master/import_export/resources.py#L44

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.