“_set em django” Respostas de código

_set em django

# Now, given object e of type Entry, you would do e.blog to access 
# the related object Blog - which is a forward relation. 

class Blog(models.Model):
    pass

class Entry(models.Model):
    blog = Blog(..)

# The _set is a reverse lookup class variable django puts in for you.    
# So, given object b - you would do:
entries = b.entry_set.all()
Panicky Pintail

_set.Filter Django

>>> r.article_set.filter(headline__startswith='This')
<QuerySet [<Article: This is a test>]>

# Find all Articles for any Reporter whose first name is "John".
>>> Article.objects.filter(reporter__first_name='John')
<QuerySet [<Article: John's second story>, <Article: This is a test>]>
Bottle Vines

Respostas semelhantes a “_set em django”

Perguntas semelhantes a “_set em django”

Mais respostas relacionadas para “_set em django” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código