39👍
✅
Your code should look like this:
(ur'^company/(?P<key>.*)/doclist/$','CompanyHub.views.docList')
We need the ‘u’ at the beginning to tell python that the string accepts unicode characters.
15👍
RegEx would look like this:
(.*)
That should match all characters except new line characters.
2👍
As others have said:
(.*)
…will match all characters, but it will also match an empty string (which might be bad if the regex is at the end of a URL). If you want to force that at least one character is required, then use this:
(.+)
Just to be clear, these work in the middle of URLs as well as at the end, so something like this works perfectly fine:
url(ur'^package\/(?P<pkgname>.+)\/(?P<pkgversion>.+)', ... )
(and as @tsikov says, use a preceding ‘u’ for unicode)
- How can I make a fixture out of QuerySet in django?
- Django. Error message for login form
- Celery – No module named five
- Sending a message to a single user using django-channels
- Django's get_current_language always returns "en"
Source:stackexchange.com