Hi
I needed a query to get the values set of a model which has multiple
child models like below
class Vehicle(models.Model):
vehicle_pkey = models.OneToOneField(User, primary_key=True,
parent_link=True)
vehiclename=models.CharField(max_length=20)
class no_of_tyres(models.Model):
no_of_tyres_pkey=models.ForeignKey
(Vehicle,related_name='no_of_tyres_relatedname')
numberoftyres=models.IntegerField()
class brand_name(models.Model):
brand_name_pkey=models.ForeignKey
(Vehicle,related_name='brand_name_relatedname')
brandname=models.CharField(max_length=20)
My first question is
Can I get all the details of the models into a single values set like
below
query_which_I_dont_know.values
('username','vehiclename','numberoftyres','brandname')
To complicate further imagine I have one more field in brand_name
which is cost
class brand_name(models.Model):
brand_name_pkey=models.ForeignKey
(Vehicle,related_name='brand_name_relatedname')
brandname=models.CharField(max_length=20)
costofvehicle=models.IntegerField()
My second question is
say I want to obtain the values set (as in the above query ) of
all the vehicle whose cost is >1000 and which has 4 numberoftyres how
can I get it
Thanks in advance
Regards
Subramanyam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---