Django Query Relations Behaviour -


okay there way filter objects records associated records. right join maybe?

basically, want select records b has foreign key whilst using clause on b. making sound more complicated is? don't need records b, a; maybe subquery?

i'm relatively new django's queries , i've done of simpler stuff.

your question little vague, if understand correctly work this:

class a(models.model):     pass  class b(models.model):     = models.foreignkey(a)     some_field = models.integerfield()  a.filter(b__some_field=5).distinct() 

this joins 2 tables , filters on b's some_field. distinct() makes sure unique as returned. see documentation on lookups span relationships.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -