Opened 13 years ago

Closed 13 years ago

#17084 closed Bug (invalid)

URL conf is evaluated after form Metas

Reported by: reames@… Owned by: nobody
Component: Uncategorized Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model form that looks something like:

class MyForm(forms.ModelForm):
  class Meta(object):
    model = Foo
    my_data = urlresolvers.reverse('myview')

This causes the following error:

Exception Type: ImproperlyConfigured

Exception Value: The included urlconf project.urls doesn't have any patterns in it

I believe this is probably because forms are evaluated before the URL resolvers are.

Change History (1)

comment:1 by Alex Gaynor, 13 years ago

Resolution: invalid
Status: newclosed

This is a natural artifact of how Python's module and import systems work. As a result, in 1.4 we introduced reverse_lazy, which works in these circumstances: https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy

Note: See TracTickets for help on using tickets.
Back to Top