Django

Code

Ticket #7206 (new)

Opened 2 days ago

Last modified 2 days ago

django.core.urlresolvers.reverse doesn't work properly

Reported by: askfor@gmail.com Assigned to: nobody
Component: Uncategorized Version: SVN
Keywords: url reverse Cc:
Triage Stage: Unreviewed Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

here is the urlpatterns

  url(r'^test/1/?',views.test1,name='test1'),
  url(r'^(?i)test/2/?$',views.test2,name='test2'),

then i test the reverse function as follows:

>>> from django.core.urlresolvers import reverse
>>> print reverse('test1')
/test/1/?

the url i expect is '/test/1/' instead of '/test/1/?' the '?' in the urlpatterns was add for matching both '/test/1/' and '/test/1'

>>> print reverse('test2')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "....django\django\core\urlresolvers.py", line 297, in
 reverse
  File "....django\django\core\urlresolvers.py", line 283, in
 reverse
  File "....django\django\core\urlresolvers.py", line 88, in
reverse_helper
  File "C:\Python25\lib\re.py", line 142, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "....\django\django\core\urlresolvers.py", line 124, in
 __call__
NoReverseMatch: Not enough positional arguments passed in

(?i) was added for matching '/test/2' or '/Test/2' and so forth

Attachments

Change History

05/09/08 10:42:43 changed by ElliottM

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

The CommonMiddleare? automatically appends slashes to the end of urls if one isn't already there, so matching both isn't necessary.

That's not to say this isn't a bug, of course.


Add/Change #7206 (django.core.urlresolvers.reverse doesn't work properly)




Change Properties
Action