I have a url conf as follows:
url(r'^books/(?{<i开发者_运维知识库d>\d+)/personal/$',twobooks.timetable.views.getPersonalizedTimetable),
and getPersonalizedTimeTable
is as follows:
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)
)
For some reason the above isn't even being called. AHHH
is not being printed to terminal and I have no idea why.
Can anyone help?
Is the url regex correct? I think there shouldn`t be { in it. You can also name parameter which you pass to view
url(r'^books/(?P<id>\d+)/personal/$',twobooks.timetable.views.getPersonalizedTimetable),
精彩评论