Traversing nested models is a mess. (or i don't get it right)

2014-05-22 Thread Adrian Scheffler
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

Re: Traversing nested models is a mess. (or i don't get it right)

2014-05-22 Thread Adrian Scheffler
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