On Sep 15, 5:21 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:

> Probably the easiest solution, if you know you're
> always going to be requesting a certain lookup, is to define a custom
> method on the model:
>
> class System(models.Model):
>     ... field declarations ...
>
>     def get_header_pic(self):
>         return
> self.system_pictures.filter(image_category__name='Header_Pic')
>
> and then in the template you can just do {{ info.get_header_pic }}


As there can be 20 or more images associated with a system, This is
more what I was looking for. Thanks!!!

However, I can't seem to get this to work.

Here are the new lines in System:

        def get_header_pic(self):
            return
self.system_pictures.filter(image_category__name='Header_Pic')

        def get_header_logo(self):
            return
self.system_pictures.filter(image_category__name='Header_Logo')

I put them just above the Class Admin: line.

Here is the new lines in the template:

    <IMG src="{{ info.get_header_pic.location }}"
width="{{ info.get_header_pic.width }}"
height="{{ info.get_header_pic.height }}" border="0"
name="{{ info.get_header_pic.name }}">

    <IMG src="{{ info.get_header_logo.location }}"
width="{{ info.get_header_logo.width }}"
height="{{ info.get_header_logo.height }}" border="0"
name="{{ info.get_header_logo.name }}">

Lance
--~--~---------~--~----~------------~-------~--~----~
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