【发布时间】:2015-02-01 18:10:10
【问题描述】:
我正在反向映射 URL 并收到错误。但我一定是误解了什么,因为它所说的不正确正是我认为我想要实现的(除了关于它不正确的部分)。
这是错误消息,为了便于阅读,我在其中添加了几个换行符:
NoReverseMatch at /k/trip/search
Reverse for 'trip/save'
with arguments '()'
and keyword arguments
'{'when': '2015-02-01',
'from_city': 'nantes',
'to_city': 'paris'}'
not found. 1 pattern(s) tried:
['k/trip/save/?P<when>(\\d{4}-\\d{2}-\\d{2})/?P<from_city>([a-zA-Z ]+)/?P<to_city>([a-zA-Z ]+)/']
完整地说,url.py 行是这样的:
url(r'^save/?P<when>(\d{4}-\d{2}-\d{2})/?P<from_city>([a-zA-Z ]+)/?P<to_city>([a-zA-Z ]+)/',
kernel.views.TripSaveView.as_view(),
name='trip/save'),
reverse 行是这样的:
return redirect(reverse('trip/save',
kwargs={
'when': trip_form['departure_date'].value(),
'from_city': trip_form['from_city'].value(),
'to_city': trip_form['to_city'].value()}))
【问题讨论】:
标签: python django python-3.x