Opened 2 years ago

Closed 2 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


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.

Attachments (0)

Change History (1)

comment:1 Changed 2 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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:

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.