0

I am using Django 1.8 on Python 3.4.3

I have a Model called FormUpload and I am adding a ModelAdmin for the same in admins.py in the same application "mca".

@admin.register(FormUpload)
class FormUploadAdmin(admin.ModelAdmin):

    def upload_form(self, request):
        context = dict(
           # Include common variables for rendering the admin template.
           self.admin_site.each_context(request),
           # Anything else we want in the context...
        )
        return TemplateResponse(request, "admin/formupload.html", context)

    def get_urls(self):
        urls = super(FormUploadAdmin, self).get_urls()
        upload_admin_urls = [
            url(r'^upload/$', self.admin_site.admin_view(self.upload_form)),
        ]
        logger.debug(upload_admin_urls)
        return upload_admin_urls + urls

This should have been available at /admin/mca/upload/ . However when I go the URL I get a 404 saying the current URL doesn't match anything

Here is the output of the debug

RegexURLPattern None ^upload/$

(Removed few things that will make the display weird for the debug).

Please notice the None. If the other URLs are listed out there is a method name where the None is.

What am I doing wrong here ? I am following the approach suggested in django documentation - https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#modeladmin-methods

Vidyanand
  • 967
  • 8
  • 14

0 Answers0