def post(self, request): form = OpinionForm(request.POST) if form.is_valid(): new_opinion = form.save(commit=False) new_opinion.user = request.user new_opinion.save() return redirect('opinion_detail', pk=new_opinion.pk) client_instance = client_check(request.user) return render(request, 'opinion/opinion_create.html', context={'form': form, 'client_img': load_client_img(client_instance)})
def get(self, request): opinions = Opinion.objects.all() form = OpinionForm() client_instance = client_check(request.user) return render(request, 'opinion/opinion_create.html', context={'form': form, 'client_img': load_client_img(client_instance), 'opinions': opinions})