0

guys. I'm passing parameters via GET requests to my view. But it seems that django is not properly handling my URL.

With parameters longer than one char, it works, but if I use a single char, I get Page not found (404) error.

Example:

Works: http://localhost:8000/my_url/test

Not found: http://localhost:8000/my_url/t

urls.py code fragment:

url(r'^my_url/(?P<username>\w.+)/$', views.my_url, name='my_url'),

Is there any django restriction to the length of parameters passed via GET? Thanks a lot in advance!

4
  • 1
    try to remove dot from regex string r'^my_url/(?P<username>\w+)/$' Commented Oct 13, 2016 at 17:15
  • @Wonder, Thanks! Now it works. But how could I also accept dots in the regular expression? Commented Oct 13, 2016 at 17:17
  • It seems to work with : r'^my_url/(?P<username>[-\w.]+)/$'. Is it right? Anyway, could you post your solution so I can accept it? Commented Oct 13, 2016 at 17:23
  • try to use characted classes. To allow all alphanumeric characters plus _, . and - replace \w+ with [A-Za-z0-9_.-]+. UPD: yeah, looks like it should work too Commented Oct 13, 2016 at 17:23

1 Answer 1

2

Remove dot from regex string r'^my_url/(?P<username>\w+)/$'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.