Import excel data into models via django admin

前端 未结 3 1011
面向向阳花
面向向阳花 2021-02-06 06:20

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 “U

3条回答
  •  耶瑟儿~
    2021-02-06 06:32

    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.

提交回复
热议问题