Answer the question
In order to leave comments, you need to log in
How to sort QuerySet by field ,,OneToOneField,,?
Required: sort the QuerySet by the field of the dependent ,,OneToOneField,, record.
,, parent ,, model
class productModel(models.Model):
price = models.PositiveIntegerField('Цена', null = True)
class characterist_pkModel(models.Model):
base_product = models.OneToOneField('productModel', on_delete= models.CASCADE)
category = models.CharField('Категория', max_length= 40, null= True)
characterist_pkModel.objects.get(pk= 1).base_product.order_by('price')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question