I have checkboxes in my css grid and there is name, type=chekbox", etc. In may view django I have captured the value of the check template with valor_xx = request.POST.get(str(xx)) # valor del check directamente desde template
in POST method.
But, all of this in my view based in function.
Last night finished with this and I'd checked this running perfectly.
You have take in mind that in template you must ask if the value check field is chequed or not with {% if.. %}..{%else%}{%endif%}. This is sent from context.
If you need some help,
Regards
Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos
Santiago de Chile
Santiago de Chile
El dom, 11 abr 2021 a las 10:49, Lars Liedtke (<liedtke@punkt.de>) escribió:
Hello,
I have got two checkboxes in a Form on Django 3.1, with which everything
works fine, but unchecking them.
I use a class derived from UpdateView and in its post() method I check
for if my form has changed. This works fine for an initial empty form
and checking form.has_changed(); after then handling the change and
calling get() with the objects id in the Browser. I get the Form back
with checked checkboxes. The values in the database are fine as well.
So now I want to test with unchecking those checkboxes and it does not
work. Form.has_changed() == False and Form.changed_data is empty. While
the correct values are in Form.cleaned_data(). But my code does not
detect these values because I check for Form.has_changed().
Am I understanding something wrong here or do I have to check if there
is a difference from the values I get in Form.cleaned_data to what my
current state in the database is myself?
I am happy to show the code. But I thought I'd ask about it in general
before posting lots of code.
---
punkt.de GmbH
Lars Liedtke
.infrastructure
Kaiserallee 13a
76133 Karlsruhe
Tel. +49 721 9109 500
https://infrastructure.punkt.de
info@punkt.de
AG Mannheim 108285
Geschäftsführer: Jürgen Egeling, Daniel Lienert, Fabian Stein
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/13e0719e-8d06-e37c-b07e-1c6deb1f84e6%40punkt.de.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKVvSDDROtUwj_HR1B5OdbjASD2udkgbyy24MXKOCxzz%3DmhyCg%40mail.gmail.com.
No comments:
Post a Comment