Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom page to django admin with custom form, not related to any Model?

I want to bulk_create models by importing csv data through django admin, with TextArea or FileField. I learned how to override template blocks, how to add new urls to django admin. But I have no idea how to solve my problem. I want to create custom admin page with my form. Pass data, parse it and bulk_create my model objects. Can you guys suggest the way how can I do this?

like image 506
Михаил Павлов Avatar asked May 29 '16 17:05

Михаил Павлов


1 Answers

Using a proxy model would save some typing:

class ImportCSVData(SomeModel):
    class Meta:
        proxy = True

@admin.register(ImportCSVData)
class MyCustomAdminForm(admin.ModelAdmin):
    ... as in accepted answer ...
like image 185
mrts Avatar answered Oct 04 '22 14:10

mrts