1

I've this pattern:

url(r'^(?P<slug>.+)-prod(?P<product_id>[0-9]+).html$', 'product_detail', name='product_detail', )

It works fine when I have:

"some unicode characters"-prod"some numbers".html

but when I have '#' sign in "some unicode characters" it doesn't match. Python/django/re truncates the string to the first character of #

For example, if I had:

"some unicode # string"-prod"some numbers".html

django will search for match

"some unicode "

Has anyone else had the same problem?

bstpierre
  • 30,042
  • 15
  • 70
  • 103
user1454592
  • 1,135
  • 1
  • 11
  • 11
  • possible duplicate of [Why the hash part of the URL is not in the server side?](http://stackoverflow.com/questions/3664257/why-the-hash-part-of-the-url-is-not-in-the-server-side) – Alasdair Jun 13 '12 at 19:49

1 Answers1

3

# is a special character as it concerns URLs. You shouldn't use it in a URL unless it's literally to indicate an anchor within the page. If you insist on using it, it should be urlencoded (i.e. %23) and you should even be able to get Django's urlresolver to match the urlencoded version.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444