2👍
✅
You can use regex to match an url.
Here’s a regex matching your two cases : [\w\d@\.-]+
.
from django.conf.urls import url
from youapp import views
urlpatterns = [
url(r'^profile/(?P<username>[\w\d@\.-]+)$', views.details, 'details')
]
Take a look at the Django documentation : https://docs.djangoproject.com/en/1.8/topics/http/urls/#how-django-processes-a-request
Source:stackexchange.com