0
处理其形式后,我需要得到我只是不停的对象的ID,以将其通过在HttpResponseRedirect:获取对象的ID在views.py
def pujar_track(request):
if request.method=='POST':
formulari = TrackForm(request.POST, request.FILES)
if formulari.is_valid():
formulari.save()
# code to get the track_id ???
return HttpResponseRedirect('/track/pujar/acoplar',track_id)
else:
formulari = TrackForm()
return render(request,'principal/trackForm.html',
{'formulari':formulari})
提前感谢!
的[Django的可能重复的关键字参数:如何获得记录刚刚保存的ID?](http://stackoverflow.com/questions/6253611/django-how-to-get-the-id-of-the-record-just-saved) – bernie 2013-02-25 19:54:57
其实上述问题不是'特定于保存表单,但这里有一个更好的匹配:http://stackoverflow.com/questions/10144475/getting-the-model-id-from-a-django-form-after-having-saved-it – bernie 2013-02-25 19:56:16