Need to check browser changeable values with using browser inspect and enter random id into url which is in button so I'm not really pro about django and stuff.I make a validation of data which is going to updated or deleted that can checked by tenantid for instance Im going press update on a single line of record and mechanics going to check if the record tenantid is equal to my tenant id or not. problem is about I cant compare query result to int value.
if any better approach about this I'ill be glad to hear, thank you have a good days.
@login_required() def customer_update(request, pk):
customer = get_object_or_404(Customer, pk=pk)
valueOwnerTenantid = Customer.objects.values_list('tenantid', flat=True).filter(id=pk)
print(valueOwnerTenantid)
print(request.user.tenantid)
print(valueOwnerTenantid.query)
if number(valueOwnerTenantid) == number(request.user.tenantid):
if request.method == 'POST':
print('Equal and POST')
form = CustomerForm(request.POST, instance=customer)
else:
print('Equal and Get')
form = CustomerForm(instance=customer)
return save_customer_form(request, form, 'customer_update_partial.html')
else:
Aucun commentaire:
Enregistrer un commentaire