Re: Problem with nested loop

2008-03-29 Thread Brandon Taylor
Thank you SO much for helping Kenneth. I just had to change 'workcategory_set' to 'worksample_set' and it's all good. I never would have found this in the documentation without knowing the '_set' keyword, but for those of you who are interested, it's in the documentation here: http://www.djangopro

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 11:43 AM, Kenneth Gonsalves wrote: > {% for w in wc %} w.title<-- forgot this > > {% for sample in w.workcategory_set.all %} > sample > {% endfor %} > > {% endfor %} -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~--

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 11:17 AM, Brandon Taylor wrote: > What I would like to accomplish is output that looks as such: > > Category name > > Sample Name > Sample Name > Sample Name > > > Category name > > Sample Name > Sample Name > Sample Name > > wc = WorkCategory.objects.all() for w

Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor
I already have my site built in Rails, and this is just a re-code in Django. I've had really good luck with it until now :) You can see the desired output (although the markup is different) at http://www.btaylordesign.com/portfolio On Mar 29, 12:47 am, Brandon Taylor <[EMAIL PROTECTED]> wrote: >

Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor
What I would like to accomplish is output that looks as such: Category name Sample Name Sample Name Sample Name Category name Sample Name Sample Name Sample Name (repeat) So, it made sense to me to start with the categories and loop through the children for each category. Is my

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 10:52 AM, Brandon Taylor wrote: > So, to simplify my question, how can I access the child objects of a > 'work_category' through the nested for loop, given my model structure? each WorkSample will have one work_category which you can access like this: worksamples = WorkSampl

Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor
Sorry, I should have just posted my code instead of trying to simplify it for the post. My apologies. Item = WorkSample WorkSample has a foreign key for the WorkCategory: work_category = models.ForeignKey(WorkCategory) I *assumed* I would be able to access any child objects of a 'work_category

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 10:30 AM, Brandon Taylor wrote: > Sure. This app is for my portfolio. Here's my models.py > > class WorkCategory(models.Model): > title = models.CharField(max_length = 30) > position = models.PositiveSmallIntegerField() > > def __unicode__(self): >

Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor
Sure. This app is for my portfolio. Here's my models.py class WorkCategory(models.Model): title = models.CharField(max_length = 30) position = models.PositiveSmallIntegerField() def __unicode__(self): return self.title class Admin:

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 10:13 AM, Brandon Taylor wrote: > Sorry, that's my fault. I was trying to simplify the naming a bit for > the post. 'work_category' should just be 'category' could you paste the relevant models also (preferably without 'simplifying') -- regards kg http://lawgon.livejournal

Re: Problem with nested loop

2008-03-28 Thread Brandon Taylor
Sorry, that's my fault. I was trying to simplify the naming a bit for the post. 'work_category' should just be 'category' On Mar 28, 11:44 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 29-Mar-08, at 9:43 AM, Brandon Taylor wrote: > > > > > def showCategories(request): > >     categories =

Re: Problem with nested loop

2008-03-28 Thread Kenneth Gonsalves
On 29-Mar-08, at 9:43 AM, Brandon Taylor wrote: > def showCategories(request): > categories = Category.objects.all().select_related() > return render_to_response('showCategories.html',{'categories': > categories}) > > > In my template, I have: > > {% for category in categories %} > {