После того, как я отправил форму в первый раз, а затем обновил sh форму, она была отправлена повторно, и я не хочу, чтобы
create_group. html:
<form id="create_group" class="form-horizontal" role="form" action="" method="post">
{% csrf_token %}
{% include 'whatsapp_blast/form_template.html' %}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button style="background-color:#FA4616;border: none;" type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
views.py:
def create_group(request):
groups = Group.objects.filter(user=request.user)
print(groups)
if request.method == "POST":
print("In IF")
form = GroupForm(request.POST)
if form.is_valid():
group = form.save(commit=False)
group.user = request.user
group.save()
# Redirect to THIS view, assuming it lives in 'some app'
return HttpResponseRedirect("whatsapp_blast.views.create_group")
else:
print("else")
form = GroupForm(request.POST)
print(form)
context = {
"form": form,
}
return render(request,'whatsapp_blast/create_group.html', context)