我的网址如下:
url(r'^books/(?{<id>\d+)/personal/$',twobooks.timetable.views.getPersonalizedTimetable),
和getPersonalizedTimeTable
如下:
def getPersonalizedTimetable(request, id):
print "AHHH"
usedTimeSlots = TimeSlot.objects.filter(user = request.user) #All the time slots that hte user has
groups = TwobooksGroup.objects.filter(users = request.user)
print groups
for group in groups:
books.append(group.book)
slots = []
for usedTimeSlot in usedTimeSlots:
slot = {
'id': usedTimeSlot.id,
'startTime': str(usedTimeSlot.startTime),
'endTime': str(usedTimeSlot.endTime),
}
slots.append(slot)
return render_to_response(
'books/personal.html',
{
'request': request,
'timeslots':slots,
'books':books,
},
context_instance = RequestContext(request)
)
出于某种原因,甚至没有调用上述内容。 AHHH
没有打印到终端,我不明白为什么。
有人可以帮忙吗?
答案 0 :(得分:4)
网址正则表达式是否正确?我认为不应该{在其中。您还可以命名传递给视图的参数
url(r'^books/(?P<id>\d+)/personal/$',twobooks.timetable.views.getPersonalizedTimetable),