when someone subscribes to the newsletter i automatically want to remove the popup for the user that just subscribed, i tried create a subscribed = False
then change it to subscribed = True
when a user subscribes. but it doesnt work. i can easily achieve this is a user is logged i, but in this case even unauthenticated users can also subscribe to the newsletter so that is where the issue comes in.
views.py
subscribed = False if request.method == "POST": form = NewsLetterForm(request.POST) if form.is_valid: form.save() messages.success(request, f"Subscription Successfull, Thank you!! - Now check your mail") subscribed = True return redirect('/') else: form = NewsLetterForm()
templates.html
{% if subscribed != True %} <p class="mb-0">Subscribe to our <b>NewsLetter</b></p> <form class="form-inline" method="POST"> {% csrf_token %} {{form.email}} <button type="submit" class="btn btn-success-soft btn-sm" type="submit">Get Now</button> {% endif %}
Advertisement
Answer
Django Close Bootstrap Modal On Submit
this solved my question for me, i had to do was close it when a user submits the form