Opened 13 years ago
Closed 13 years ago
#17084 closed Bug (invalid)
URL conf is evaluated after form Metas
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.
Note:
See TracTickets
for help on using tickets.
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