Quantcast
Channel: How to make trailing slash optional in django - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Mojtaba Kamyabi for How to make trailing slash optional in django

$
0
0

You can use re_path instead of path for use regular expression in your url pattern. use ? sign in your url like this:

from django.urls import re_pathre_path(r'url/?$', views.appmain, name="main")

Note: question mark matches zero or one / in the url. it accepts both domain.com/url and domain.com/url/


Viewing all articles
Browse latest Browse all 3

Trending Articles