Opened 16 years ago

Closed 16 years ago

#8897 closed (invalid)

Peculiarity in url template tag - lookup fails when view name enclosed in single quotes

Reported by: jacob.martin@… Owned by: nobody
Component: Template system Version: 1.0
Severity: 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

Does what it says on the tin.

Old, non-working code example:

urls.py

urlpatterns = patterns('',
    url(r'^servicemanagement/status/$', 'nwwcfh.servicestatus.views.map_details', name='map-details'),

intended template usage:

<li><a href="{% url map-details %}" title="View an map of current service status">Service Status</a></li>

This fails, giving one of two errors (seemingly at random): either "there is no module named urls" or a message complaining that "map-details" can't be reversed.

Fix:

urlpatterns = patterns("",
    url(r'^servicemanagement/status/$', "nwwcfh.servicestatus.views.map_details", name="map-details"),

(i.e. use double quotes instead of single quotes )

Why does this work? Don't know. But it took me the best part of a day to figure this out!

Change History (1)

comment:1 by mrts, 16 years ago

Resolution: invalid
Status: newclosed

Impossible,

>>> '' is ""
True

i.e. they are the same thing for Python. The bug *is* somewhere else (e.g. the url tag fails on some db inconsistencies etc -- I have been bit by invalid slugs for example, but the exception should tell you all the details). Please reopen if there is a real bug and do paste a backtrace.

Note: See TracTickets for help on using tickets.
Back to Top