kater
kater

Reputation: 139

Reverse django admin custom url with reverse

I have model admin view to which I added custom view like below. Then I'm using jQuery to upload a csv file.

def get_urls(self):
    urls = super(MyAdminView, self).get_urls()
    my_urls = [
        path('upload_csv/', self.upload_csv, name='upload_csv'),
    ]
    return my_urls + urls

My problem is that I don't know how to reverse url to that view in tests.

Upvotes: 2

Views: 743

Answers (1)

Exprator
Exprator

Reputation: 27533

in redirect or reverse

you can use

admin:app_name:upload_csv

or if no app is related to this url

admin:upload_csv

Upvotes: 5

Related Questions