Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import excel data into models via django admin

I need the Django Admin interface to accept administrator uploads of Excel files where the data in each Excel file is inserted into my database models. How can I make such an “Upload” button appear on a Django model admin page, where clicking the button asks the administrator to choose an .xls file, whose data then gets added to database once its upload is complete?

like image 879
RdB Avatar asked Apr 02 '12 20:04

RdB


People also ask

Can I use Django admin in production?

your company should follow a least access principle policy; so yes: only select people should have access. Django has basic auditing capability via signals and displayed in the admin out of the box. You can build on top of this.


1 Answers

django-import-export could be helpful.

It creates two buttons "import" and "export" for admin objects and permits select many types of extensions, including xls. It also show the data do be imported and asks to be confirmed before execute the execution.

You just need to include it in INSTALLED_APPS and create an import-export resource of the class you want to upload and a subclass of ImportExportModelAdmin related to the resource class created before to show buttons in admin.

more info at:

http://django-import-export.readthedocs.org/en/latest/getting_started.html https://github.com/bmihelac/django-import-export.

like image 76
Farah Avatar answered Nov 14 '22 19:11

Farah