I know this is a question that has been around in different formats, but for some reason, I can't find a solution for myself.
The problem:
when I'm adding a checkbox in django admin, I can see it on page, but not in forms, when I'm trying to edit item outside of the admin (using Boostrap forms).
here is my html file for edit:
<div class="checkbox">
<label class="form-check-label" for="inputprocurement" style=color:#D3D3D3>On Order:</label>
<input type="checkbox" class="form-check-input" id="inputprocurement" aria-describedby="editprocurement" value="" name = "on_orderp">
</div>
here is a relevant part from models.py file:
on_orderp = models.BooleanField("inputprocurementcheck", default = False)
and the view.py:
def edit_procurement(request, listp_id):
if request.method =='POST':
current_itemp = Procurement.objects.get(pk=listp_id)
# add `request.FILES or None` for file upload
form = ProcurementForm(request.POST or None, request.FILES or None, instance=current_itemp)
if form.is_valid():
form.save()
messages.success(request, ('Item Has Been Edited!'))
return redirect('procurement')
else:
messages.success(request, ('Seems Like There Was An Error...'))
return render(request, 'edit_procurement.html', {})
so, when I have a checkbox on my item:
I can't see the checked box, when I'm on my forms in edit:
and if the checkbox is on, and I'm testing the edit function with a checkbox on, nothing is changed.
if the checkbox is on, and I'm testing the edit function with a checkbox off, checkbox is getting unchecked in the system,
when the checkbox is unchecked in the system and I'm trying to tick it using forms, nothing changes with an error.
all the other fields work fine.
maybe someone can help me with this.
Aucun commentaire:
Enregistrer un commentaire