python - How to reverse a custom admin url in Django 1.5? -
i want add custom url modeladmin seems django changed template syntax in 1.5. tried way documentation pointed out unfortunately doesn't work.
class variableadmin(admin.modeladmin): def get_urls(self): urls = super(variableadmin, self).get_urls() my_urls = patterns('', url(r'^settings/([a-za-z0-9]*)', self.admin_site.admin_view(self.settings), name="settings")) return my_urls + urls def settings(self, request, category): return render_to_response('variables.html', {"opts": variable._meta}))
here variables.html
{% load admin_urls %} {% url opts|admin_urlname:'settings' %}
this code throws error this:
reverse 'common_variable_settings' arguments '()' , keyword arguments '{}' not found.
how can fix problem?
try changing name of view include application , model names:
... my_urls = patterns('', url(r'^settings/([a-za-z0-9]*)', self.admin_site.admin_view(self.settings), name="common_variable_settings")) ...
the admin_urlname
template filter returns "full" names, see it's source code:
@register.filter def admin_urlname(value, arg): return 'admin:%s_%s_%s' % (value.app_label, value.module_name, arg)
so need name view "appname_modulename_settings"
. maybe try changing regular expression this:
r'^settings/([a-za-z0-9]+/)?$'
Comments
Post a Comment