1π
β
The uom_binuom_set
is for a single UOM
instance
UOM.objects.get(pk=1).uom_binuom_set.all()
However, you have UOM_BINUOM.objects.filter(...)
, which is a queryset. As the error says, the queryset does not have the uom_binuom_set
method.
You can construct the queryset you want by starting with the UOM_BINUOM
model.
uombinuom = UOM_BINUOM.objects.filter(UOM__material=material_id)
Note that since material_id
is a single id, you donβt need to use __in
.
π€Alasdair
1π
When you do
uom = material.uom_set.all().order_by('-id')
uom
is a QuerySet
here. uom_binuom_set
should be called on single record not QuerySet of records.
So you will need to iterate over the uom
QuerySet and call .uom_binuom_set.all()
for each record.
for record in uom:
uom_binuom = record.uom_binuom_set.all()
# do something with uom_binuom
Or if you want only first records related uom_binuom
then
uom_binuom = uom.first().uom_binuom_set.all()
π€Muhammad Tahir
- [Answered ]-Django: Not allowing newly-created user to log in until he/she is approved by the admin?
- [Answered ]-Django: TypeError: 'x' is an invalid keyword argument for this function
- [Answered ]-Updating account balance with django
- [Answered ]-Change local based on object
- [Answered ]-Django uploading a file from a form fails to validate
Source:stackexchange.com