Search Results

Search found 1 results on 1 pages for 'swoei'.

Page 1/1 | 1 

  • Query multiple models with one value

    - by swoei
    I have multiple models which all have a FK to the same model. All I know is the FK how can I determine which of the models has the FK attached? Below an example to clearify: class ModelA(models.Model): title = models.CharField("title", max_length=80) class ModelB(models.Model): fk = models.ForeignKey(ModelA) class ModelC(models.Model): fk = models.ForeignKey(ModelA) How can I figure out without using a try/except on each model whether B or C has the FK? (The FK can only be in one of them, for the record in this case I only added two models but in the real world app there are multiple possible x amount of models which have the FK to modelA)

    Read the article

1