﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11712	First use of reverse() freezes its cache	beuc@…	nobody	"I'm using a reverse() for a 'post_save_redirect' parameter, that refers to a view declare above.

This doesn't work if said view is declared in the same patterns block, so I'm using several patterns blocks.

However, and that's the main issue, all view declared later in the code are ignored. Example:

{{{
from django.conf.urls.defaults import *
from django.core.urlresolvers import reverse, clear_url_caches
from django.contrib.auth.forms import UserChangeForm
from django.contrib.auth.models import User, Group

urlpatterns = patterns('',
  url(r'^user/$',
      'django.views.generic.list_detail.object_list',
      { 'queryset': User.objects.all(), },
      name='user_list'),
)

urlpatterns += patterns('',
  url(r'^user/(?P<object_id>[a-zA-Z0-9_]+)/$',
      'django.views.generic.create_update.update_object',
      { 'form_class': UserChangeForm,
        'post_save_redirect': reverse('user_list'), },
      'utilisateur_detail'),
)

urlpatterns += patterns('',
  url(r'^group/$',
      'django.views.generic.list_detail.object_list',
      { 'queryset': Group.objects.all(), },
      name='group_list'),
)

test = reverse('group_list')
}}}

=> Reverse for 'group_list' with arguments '()' and keyword arguments '{}' not found.

The important part is:
{{{
'post_save_redirect': reverse('user_list'),
}}}
change it to:
{{{
'post_save_redirect': 'whatever',
}}}
and everything works fine.

This sounds like a cache issue, but interestingly calling clear_url_caches() before the last line doesn't help.

In 1.0.2 this is a one-time error that disappears on the next reload so it's not very important.

On 1.1, this is a permanent error which is very confusing and long to track: the view's reverse name is properly defined, but still Reverse says it cannot find it.

I'm not sure I understand all the aspects of this issue, but to the least, its error reporting needs to be improved.
"	Bug	closed	Core (Other)	1.1	Normal	fixed	urlresolvers, reverse		Accepted	0	1	0	0	0	0
