Thursday, July 18, 2013

NoReverseMatch when proxy model's parent is not registered on admin site.

Django 1.6 has a (documented) difference in handling NoReverseMatch on templates. I noticed that it causes a problem when I don't register proxy mode's parent on admin site.

I have defined two models (actually three but only two is needed to reproduce). Here is a simple example:

models.py:
from django.db import models

class Base(models.Model):
pass

class ProxyForBase(Base):
class Meta:
proxy=True

admin.py:
from django.contrib import admin
from .models import *

# I don't want to register Base
admin.site.register(ProxyForBase)

Admin fine now, but when I create a model with ProxyForBase's admin view and then try to access the frontpage of the admin site I get this error:
NoReverseMatch at /admin/
Reverse for 'myapp_base_change' with arguments '('1',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Is this really intended behaviour or a bug? On Django 1.5.1 this worked fine but fails on 1.6 beta 1. Is there any workaround or do I have to register Base model (or equivalent)?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate