Closed Hexomika closed 2 weeks ago
could you provide a min python code that i can reproduce this error.
from django.shortcuts import render
from web.forms import ContactForm
from django.views import View
from django.http import JsonResponse
from base.settings import EMAILS, DOMAIN
from web.models.constants import services, places, testimonials
class HomeView(View):
form_class = ContactForm
html_template_name = "public/pages/home.html"
email_template_name_to_us = "mailing/contact_email_to_us.html"
email_template_name_to_prospect = "mailing/contact_email_to_prospect.html"
def get(self, request, *args, **kwargs):
form = self.form_class()
return render(
request,
self.html_template_name,
context={
"services": services,
"places": places,
"testimonials": testimonials,
"form": form,
"domain": DOMAIN,
},
)
def post(self, request, *args, **kwargs):
"""
Sends a mail to hps teams and
the prospect to confirm contact form
"""
form = self.form_class(request.POST)
if form.is_valid():
last_name = form.cleaned_data["last_name"]
email_object = form.cleaned_data["email_object"]
# noreply to default
form.send_mail(
subject=f"Demande de contact de Mme, Mr, {last_name} pour {email_object}", # noqa
html_template=self.email_template_name_to_us,
sender=EMAILS["noreply"],
recipient=[EMAILS["default"]],
)
# default to prospect
form.send_mail(
subject=f"Votre requête a bien été envoyé à Hygiène Protection Service 3D", # noqa
html_template=self.email_template_name_to_prospect,
sender=EMAILS["default"],
recipient=[form.cleaned_data["email"]],
extra_context={"domain": DOMAIN},
)
return JsonResponse({"data": "Votre requête a bien été envoyé"})
errors = {field: form.errors.get(field) for field in form.fields}
return JsonResponse({"errors": errors})
should be fixed.
Hello, I got an error while scrolling (in a Python file).
commit: 0ebb3e2
Thanks for your work !
Mickaël