输入EventForm
字段后,我没有被重定向到display:eventexe
,即EventDetailView
。相反,我被重定向到我输入表单详细信息的同一页面。
views.py
class FileEventView(FormView):
template_name = 'display/events.html'
form_class = EventForm
def form_valid(self, form):
event_up = EventModel()
event_up.save()
self.id = event_up.id
return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
return reverse('display:eventexe', kwargs={'pk': self.id})
class EventDetailView(DetailView):
model = FileModel
template_name = 'display/eventexe.html'