0
要麼我得不到足夠的睡眠,要麼我錯過了明顯的東西。在基於Django Class的視圖中的HttpResponseRedirect之後顯示消息
無論我做什麼,我都無法從HttpResponseRedirect之後的基於類的視圖中顯示消息。
這是我的觀點:
class Add(SuccessMessageMixin, LoginRequiredMixin, CreateView):
template_name = "apps/add.html"
form_class = forms.Add
success_message = "Report was added successfully"
def form_valid(self, form):
team = get_object_or_404(t_models.Team, owner=self.request.user)
self.object = form.save(commit=False)
self.object.team = team
self.object.recorded_by = self.request.user
self.object.save()
form.save_m2m()
return HttpResponseRedirect(self.get_success_url())
def get_success_url(self):
return reverse('thing_detail', kwargs={'pk': self.object.id})
到目前爲止,我仔細檢查過,我有所有的會話設置權,設置所有的消息了正確的,我已經重新啓動了VE和刷新緩存。
有什麼建議嗎?