Code

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

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.

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: https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse-lazy

Add Comment

Modify Ticket

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


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

 
Note: See TracTickets for help on using tickets.