Saturday, July 30, 2011

Re: NoReverseMatch for custom admin URLs [SOLVED]

Sorry, my bad :)

I forgot that first argument for patterns() is a string with view name
prefix. That was all.

Martin

On Sat, 30 Jul 2011 11:52:21 +0200, Martin Tiršel <django@blackpage.eu>
wrote:

> Hi all,
>
> the code:
>
> class CompanyProfileAdmin(admin.ModelAdmin):
> list_display = (
> '__unicode__',
> 'city',
> 'premium_type',
> 'followers',
> 'manage_premium_account'
> )
> ...
> def get_urls(self):
> urls = super(CompanyProfileAdmin, self).get_urls()
> my_urls = patterns(
> url(
> r'^some_view/$',
> self.admin_site.admin_view(self.manage_premium_account_view),
> name='manage_premium_account'
> ),
> )
> return my_urls + urls
>
>
> def manage_premium_account_view(self, request, context={}):
> ...
>
>
> class CompanyProfile(models.Model):
> ...
> def manage_premium_account(self):
> return '<a href="%s">Manage</a>' % reverse(
> 'manage_premium_account',
> args=(self.id,)
> )
> manage_premium_account.short_description = 'Action'
> manage_premium_account.allow_tags = True
>
>
> And I get NoReverseMatch exception if I try to reverse
> `manage_premium_account`. Does anybody know why and how to solve it?
>
>
> Thanks,
> Martin

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment