1
我有添加和編輯Meeting
對象,我保存Meeting
對象顯示對象的與會者名單後去一個觀點,我怎麼能返回參與者的列表與HttpResponseRedirect
?我不認爲有可能通過query string
發送一個大對象列表!返回對象的列表,HttpResponseRedirect
在views.py
def addMeeting(request,meeting_id=None):
message=u''
participants=Participant.objects.filter(meeting__id=meeting_id)
if request.GET.get('save'):
message='your recorded was registered'
if meeting_id:
meeting_instance=Meeting.objects.get(pk=meeting_id)
else:
meeting_instance=Meeting()
if request.method=='POST':
meetingform=MeetingForm(request.POST,instance=meeting_instance)
if meetingform.is_valid():
meeting=meetingform.save()
meeting.save()
redirect_url=reverse('MeetingManagerHub.views.addMeeting', args=[meeting.pk])
return HttpResponseRedirect(redirect_url+'?save=True')
else:
meetingform=MeetingForm(instance=meeting_instance)
return render_to_response('MeetingHub/addmeeting.html', {'meetingform': meetingform,'message':message},context_instance=RequestContext(request))
在urls.py
(r'^meeting/add/$','MeetingManagerHub.views.addMeeting'),
(r'^meeting/add/(?P<meeting_id>\d+)/$','MeetingManagerHub.views.addMeeting'),
我用Google搜索了很多,終於發現了HttpResponseRedirect只是我們重定向到一個新地址,不與context
工作!
我該怎麼做?
不知道如果我把那個叫「祕密」) – 2012-02-28 18:10:00
TNX所以muchhh,相信這是一個祕密:))) – 2012-02-28 18:51:48