Hi,
    This is my first Django/DB project, so pardon for the naivete of
the question.

    I have one relation in my DB which I cannot - whatever I think of
- seem to do it in a single DB check. Since I have around 5 other
separate SQL statements in that same view, I am worried about the
performance of the system. Is it possible for someone to help me out
how to do it in a single DB check?

 Models:
class CarType(models.Model):
    type models.Charfield(max_length=32)

class CarName(models.Model);
    name models.CharField(max_length=32, unique=True)
    cartype models.ForeignKey(CarType)

class Buyers(models.Model):
     invoice models.IntegerField()
     ...
     cartype models.ForeignKey(CarType)

Now, I have input as car name, which is associated with the car type.
I need to get the buyer details wherein the car type is the same as
the cartype associated with the car name.
Currently, I do the following;
carNameObj = CarName.objects.filter(name__exact=iName)
buyerDetails = Buyers.objects.filter
(cartype__exact=carNameObj.cartype)

As can be seen, there are two separate DB checks for something which I
feel should be done in a single DB check. Is it possible for someone
to help me out?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to