[Answered ]-Optional some special characters such as @, – or . in Django URL

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

Leave a comment