Hi there.
supposed you've got a nested model like this:
class Article(models.Model):
parent_article = models.OneToOneField("self", blank=True, null=True,
default=None, related_name="child_article")
How would you traverse the related model chain ( aka linked list ) to one
end?
Maybe with a g
Okay, got it (at least i hope so :-) ):
def article_child_gen(article):
while True:
try:
article = Article.objects.get(parent_article=article)
yield article
except Article.DoesNotExist:
return
--
You received this message because you are sub
2 matches
Mail list logo