#26428: test.Client doesn't fully support relative-path reference in Redirects -----------------------------------+-------------------- Reporter: master | Owner: nobody Type: Bug | Status: new Component: Testing framework | Version: 1.9 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------------+-------------------- Consider this definition, in a reusable app: {{{ url(r'^inbox/$', InboxView.as_view(), name='inbox'), url(r'^$', RedirectView.as_view(url='inbox/')), }}} And {{{ urlpatterns = [ url(r'^messages/', include((app_name_patterns, 'app_name'), namespace='app_name')), ] }}} This was working on 1.8, thanks to http.fix_location_header, which converts the url to something like {{{http://testserver/messages/inbox/}}}.
1.9 introduced the "HTTP redirects no longer forced to absolute URIs" change and the fix has disappeared, the reason being "... allows relative URIs in Location, recognizing the actual practice of user agents, almost all of which support them.". Unfortunately, this is not fully the case of test.Client. It doesn't support relative-path reference - not beginning with a slash character, but only absolute-path reference - beginning with a single slash character ([https://tools.ietf.org/html/rfc3986#section-4.2, ref]). A GET to {{{inbox/}}} leads to 404. I'm using a workaround with {{{... url=reverse_lazy('app_name:inbox') ...}}}, referred by a TestCase.urls attribute, to produce {{{/messages/inbox/}}}, but I'm not happy with this hardcoded namespace. -- Ticket URL: <https://code.djangoproject.com/ticket/26428> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.c23a7f13c5259585f30d2513e8fbacfc%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.