Opened a ticket - https://code.djangoproject.com/ticket/21022
On 2 September 2013 14:37, Russell Keith-Magee wrote:
>
> I agree with Marc -- the fix here is that you should be using a named URL,
> not referencing the view directly. The circular dependency shouldn't
I agree with Marc -- the fix here is that you should be using a named URL,
not referencing the view directly. The circular dependency shouldn't exist
- it should be broken by the dereferencing provided by the URL name. This
is a feature that was added late in the development of Django (well…
I think the main issue here is using the view (name OR instance) as the
reference. We really should be pushing naming of urls more in the
documentation - they're always mentioned but as a "you might prefer to do
this" rather than a "use URL names on every URLpattern and in reverse. You
could also
Given both the docs for get_absolute_url and reverse demonstrate using
string references only, I think adding in clarification of why it's
preferred is worthwhile.
I still find it surprising how often I need to tell people on #django to
not import models just to reference them in relation
The way I stumbled across this problem was:
1. views imports models and forms (both are normally needed)
2. forms imports models (for ModelForm)
3. models imports views (for get_absolute_url), e.g.:
import views
class MyModel(models.Model):
get_absolute_url(reverse(views.myview))