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:
                ordering = ('position',)
                search_fields = ('title', 'position')

        class Meta:
                verbose_name_plural = 'Work Categories'


class WorkType(models.Model):
        title = models.CharField(max_length = 40)

        def __unicode__(self):
                return self.title

        class Admin:
                pass

        class Meta:
                verbose_name_plural = 'Work Types'


class Client(models.Model):
        position = models.PositiveSmallIntegerField()
        name = models.CharField(max_length = 50)
        url = models.CharField(max_length = 50, blank = True)
        display = models.BooleanField()

        def __unicode__(self):
                return self.name

        class Admin:
                list_display = ('position','name','url','display')
                list_filter = ('display',)
                ordering = ('name',)
                search_fields = ('name', 'position')

        class Meta:
                ordering = ['name']


class WorkSample(models.Model):
        work_category = models.ForeignKey(WorkCategory)
        work_type = models.ForeignKey(WorkType)
        client = models.ForeignKey(Client)
        title = models.CharField(max_length = 75)
        desc = models.TextField()
        thumbnail = models.ImageField(upload_to = 'images')
        sample_image = models.ImageField(upload_to = 'images')
        sample_alt = models.CharField(max_length = 75)
        slug = models.SlugField()

        def __unicode__(self):
                return self.title

        def get_absolute_url(self):
                return u'/portfolio/view/%s' % self.slug

        class Admin:
                list_display = ('title','desc','sample_alt','slug')
                list_filter = ('work_category', 'work_type', 'client')
                search_fields = ('client', 'desc')

        class Meta:
                verbose_name_plural = 'Work Samples'


I thought I could probably loop through the work samples by saying:

{% for work_sample in work_category.work_samples %}{% endfor %}

But when I return the length of child records:
{{ work_category.work_samples|length }}
I get 0.

Thoughts?

On Mar 28, 11:55 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> 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
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to