Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My Django URLs not picking up dashes

People also ask

How Django URLs work with regular expressions?

We use regular expressions to match these url paths to their corresponding request handler (aka View). If a path, either dynamic or static, is matched the View will then handle the request and return a response to the User. If a path is not matched, Django will automatically send a 404 Page Not Found response.

What happens if you skip trailing slash in Django?

If you're creting a RESTful API using Django, this can be a good solution when developers POST data directly to endpoint URL. When using APPEND_SLASH , if they accidently sent it without trailing slash, and your urlconf is WITH a trailing slash they would get an exception about data lose when redirecting POST requests.

Is URL deprecated in Django?

Yes, if they upgrade to django-4.0, url will no longer be available.

How do I reference a URL in Django?

Django offers a way to name urls so it's easy to reference them in view methods and templates. The most basic technique to name Django urls is to add the name attribute to url definitions in urls.py .


Try: ^(?P<page>[-\w]+)/$

[-\w] will accept a-z 1-9 and dash