Re: looping to create an array of category breadcrumbs

2008-10-29 Thread Dj Gilcrease
def get_parent(self): if self.parent: return [self.parent] return [] def get_parent_tree(self): asc = self.get_parent() for p in asc: asc.extend(p.get_parent()) return asc This is what I use for generating a category crumb

Re: looping to create an array of category breadcrumbs

2008-10-29 Thread coderb
hi Thomas, thanks for all the details, actually my post was not really clear on what I have. the category model looks like this: class Category(models.Model): name = models.CharField(max_length=100, unique=True) slug = models.SlugField(max_length=100, unique=True) p

Re: looping to create an array of category breadcrumbs

2008-10-29 Thread Thomas Guettler
Hi, Does this help you? myslug=... parents=[] while myslug: cat_crumb=Category.objects.get(slug=myslug) # I guess slug is unique parents.append(cat_crumb) myslug=cat_crumb.parent But be careful, you might get infinite loops if the parent links to a child. To avoid this you could write

Re: looping to create an array of category breadcrumbs

2008-10-28 Thread coderb
sorry, had not finished this post before accidently submitting it... for myslug not null catcrumb_list = Category.objects.filter(slug=myslug) myslug = catcrumb_list.parent basically, I want to loop through the category model a parent is not found, and each pass, store the model tupel in