4

I want to get the result in one list using three different models in django. How do i apply join over three models.

class CurrentDomainChecks(models.Model):

    domain = models.ForeignKey(Domains)
    check_type = models.ForeignKey(CheckType)
    check_date = models.DateTimeField(auto_now_add = True, primary_key=True)
    check_value = models.CharField(_('check value'), max_length = 2048)
    check_passed = models.BooleanField(default = False)

class DomainStatus(models.Model):

    domain = models.ForeignKey(Domains)
    domain_status_date = models.DateTimeField(auto_now_add=True,null = True, blank = True)
    domain_status = models.IntegerField(null = True, blank = True)

class Domains(models.Model):

    domain_name = models.CharField(_('domain name'), max_length = 255, unique = True)
    verified = models.BooleanField(default = False)
    user = models.ForeignKey(User)
    date_added = models.DateTimeField(auto_now_add=True,null = True, blank = True)
    date_last_changed = models.DateTimeField(auto_now=True,null = True, blank = True)
    monitoring_frequency = models.CharField(_('monitoring frequency'), max_length = 20,blank = True,null = True)

    def __unicode__(self):
        return self.domain_name 
jvallver
  • 2,230
  • 2
  • 11
  • 20
PythonDev
  • 4,287
  • 6
  • 32
  • 39
  • 1
    Could you add something about the result your are expecting? Some inputdata and expected output. It will help to understand your question. – VGE Jun 21 '11 at 12:54
  • possible duplicate of [Django: implementing JOIN using Django ORM?](http://stackoverflow.com/questions/4125379/django-implementing-join-using-django-orm) – Ajoy May 20 '15 at 12:49

2 Answers2

8

Did you read this about JOIN ?

Django: implementing JOIN using Django ORM?

Community
  • 1
  • 1
VGE
  • 4,171
  • 18
  • 17
4

"Lookups that span relationships"

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358