Как получить данные из Post
Имеется такой код:
@method_decorator(login_required, name='dispatch')
class MainFormView(DataMixin, FormView):
form_class = MainForm
template_name = 'sitee/index.html'
success_url = reverse_lazy('home')
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(**kwargs)
context['menu_selected'] = 'home'
c_def = self.get_user_context(title="Главная")
return dict(list(context.items()) + list(c_def.items()))
def form_valid(self, form):
# print(POST)
#context['result'] = POST['title']
return redirect('home')
#index.html
<form method="post">
{% csrf_token %}
<div class="form-error">{{ form.non_field_errors }}</div>
<input id="title" name="title" type="text"/>
<input id="datetime" name="datetime" type="text"/>
<label for="id_groups_0">
<input type="checkbox" name="groups" value="0" id="id_groups_0">
Группа 2
</label>
<label for="id_groups_1">
<input type="checkbox" name="groups" value="0" id="id_groups_1">
Группа 1
</label>
<button type="submit">Отправить</button>
</form>
{{result}}
При попадании на страницу home появляется эта форма. Как после нажатия на "Отправить", вывести данные из post запроса, добавить в контекст значение из post['title'] и вывести на страницу