python - Urls in Django 1.7 when the Url Contains spaces -
i have app user can create events. once event created there link event supposed go event details page.
the href looks this:
<a href="/events/view/{{event.event_name}}">event details </a>
so sample url looks this:
http://www.example.com/events/view/food%20drive%20la
the %20 giving me problem, can't render urls spaces. think regular expression incorrect in events urls.py:
url(r'^view/(?p<event_name>[\w%20+])$', views.event_details, name='event_details'),
here views.py:
def event_details(request, event_name): event_name = event_name #... return render_to_response('events/event_details.html')
what issue here?
don't worry space percent-encoding in url, on django url configuration level continue thinking usual space:
^view/(?p<event_name>[\w\s]+)$
also see:
Comments
Post a Comment