Tired your link for the form. If this is the form you are concerned about then the message that pops up is for validation i.e. form.is_valid().
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/dQklGcV6ayQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/725525470.7515030.1596074301490%40mail.yahoo.com.
Remember to include the csrf_token tag in all forms that are submitted via POST.
You should never compare the complete HTML content. Just check the functionalities. In case you need disabling the csrf
at
any cost, following logic should help I guess.
In your views.py
file,
add the following package
from
django.views.decorators.csrf import csrf_exempt
Then just before the function definintion, in which you are performing your checks, add this snippet:
@csrf_exempt
This will disable the default verification of csrf. Even if your incoming request has a hidden csrf token, your server function will completely ignore it. This should do the trick of disabling the csrf.
reply = django.shortcuts.redirect("/ admin_status")
else:
both = [(e, form.fields[str(e.id)]) for e in appts]
reply = django.shortcuts.render( request,
"admin_status.html",
{"both" : both})
else:
form = grandmas4hire.forms. StatusForm()
both = [(e, form[str(e.id)]) for e in appts]
reply = django.shortcuts.render( request,
"admin_status.html",
{"both" : both})
return reply
Here is the dynamic form StatusForm....
class StatusForm(django.forms.Form):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for e in grandmas4hire.models. Appointment.objects.all():
self.fields[str(e.id)] = \
django.forms.BooleanField( required = False)
(I need to make a dynamic form because I needed 1 field for each Appointment object.)
Chris