why i am having getting this error ? ["“('1',)” value must be either True, False, or None."] did i miss something in my code? i am trying to update the data and i receive this error.
This is my html
<input type="checkbox" name="Ubo" value="1" {% if feedback.q5Ubo %}checked="check" {% endif %}>
<input type="checkbox" name="Lagnat" value="1" {% if feedback.q5Lagnat %}checked="check" {% endif %}>
<input type="checkbox" name="Sipon" value="1" {% if feedback.q5Sipon %}checked="check" {% endif %} >
<input type="checkbox" name="Lbm" value="1" {% if feedback.q5LBM %}checked="check" {% endif %}>
This is my views.py
Ubo = request.POST.get('Ubo') or 0
Lagnat = request.POST.get('Lagnat') or 0
Sipon = request.POST.get('Sipon') or 0
Lbm = request.POST.get('Lbm') or 0
this is my models.py
q5Ubo = models.BooleanField(default=False, blank=True, null=True)
q5Lagnat = models.BooleanField(default=False, blank=True, null=True)
q5Sipon = models.BooleanField(default=False, blank=True, null=True)
q5LBM = models.BooleanField(default=False, blank=True, null=True)
UPDATE i change my html and views.py
html
<input type="checkbox" name="Ubo" value=True>
<input type="checkbox" name="Lagnat" value=True >
<input type="checkbox" name="Sipon" value=True >
<input type="checkbox" name="Lbm" value=True >
views.py
Ubo = bool(request.POST.get('Ubo')) or False
Lagnat = bool(request.POST.get('Lagnat')) or False
Sipon = bool(request.POST.get('Sipon')) or False
Lbm = bool(request.POST.get('Lbm')) or False
this is the traceback
Traceback (most recent call last):
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/MyHealth/contacttracingapp/TracingSettings/TracingApp/views.py", line 865, in Data
insert_2tab.save()
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
updated = self._save_table(
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/base.py", line 872, in _save_table
updated = self._do_update(base_qs, using, pk_val, values, update_fields,
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/base.py", line 926, in _do_update
return filtered._update(values) > 0
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/query.py", line 803, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1522, in execute_sql
cursor = super().execute_sql(result_type)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1143, in execute_sql
sql, params = self.as_sql()
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1488, in as_sql
val = field.get_db_prep_save(val, connection=self.connection)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 823, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 818, in get_db_prep_value
value = self.get_prep_value(value)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 967, in get_prep_value
return self.to_python(value)
File "/home/MyHealth/contacttracingapp/ctenv/lib/python3.8/site-packages/django/db/models/fields/__init__.py", line 957, in to_python
raise exceptions.ValidationError(
Exception Type: ValidationError at /Data/
Exception Value: ['“(False,)” value must be either True, False, or None.']
this is my full views.py
q1 = request.POST.get('q1')
q2 = request.POST.get('q2')
q2Reason = request.POST.get('q2Reason')
q3 = request.POST.get('q3')
q4 = request.POST.get('q4')
q4Reason = request.POST.get('q4AnswerDetailed')
q5 = request.POST.get('q5')
q6visitedPlacesDuringNonWorkingDays = request.POST.get('q6visitedPlacesDuringNonWorkingDays')
Ubo = bool(request.POST.get('Ubo')) or False
Lagnat = bool(request.POST.get('Lagnat')) or False
Sipon = bool(request.POST.get('Sipon')) or False
Lbm = bool(request.POST.get('Lbm')) or False
paghinga = bool(request.POST.get('paghinga')) or False
Pananakit = bool(request.POST.get('Pananakit')) or False
katawan = bool(request.POST.get('katawan')) or False
Pagkawala = bool(request.POST.get('Pagkawala')) or False
insert_2tab = TrEmployeeSuppliersFeedbackQuestionsSubmittedRecords(
dateSubmitted=datenow,
fmCustomerID=company,
fmCustomerEmployeeSupplierID=fmCustomerEmployeeSupplierID,
q1Answer=q1,
q2Answer=q2,
q2AnswerDetailed=q2Reason,
q3Answer=q3,
q4Answer=q4,
q4AnswerDetailed=q4Reason,
q5Answer=q5,
q5Ubo=Ubo,
q5Lagnat=Lagnat,
q5Sipon=Sipon,
q5LBM=Lbm,
q5HirapSaPaghinga=paghinga,
q5PananakitngUlo=Pananakit,
q5PananakitngKatawan=katawan,
q5PagkawalaNgPangAmoyatPanlasa=Pagkawala
)
insert_2tab.save()