lundi 8 juin 2015

Joining multiple tables for a single report in Django

From the example dataset below, how would I query, either through django.db or through the database API to get the request result?

I want to query the data set to get all items new than a specified date in A, but I only want the name and color from B and the taste from C.

class A(models.Model):
    export_date = models.DateField()

class B(models.Model):
    name = models.CharField()
    color = models.CharField()
    weight = models.CharField()
    a = models.ForeignKey(A)

class C(models.Model):
    taste = models.CharField()
    smell = models.CharField()
    a = models.ForeignKey(A)

Aucun commentaire:

Enregistrer un commentaire