我需要获取我刚刚保留的对象的 id,以便在 HttpResponseRedirect 中传递它:
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})
提前致谢!