Hi all,

I have recently started with django and have been able to do good work
with the excellent documentation. Thank you.

However, now I am a little baffled. I have created a gallery app. The
model exists of a Gallery and Photo which has a foreign key to the
Gallery.

Now if I want to use the function photo.get_next_by_date in a template
and there is a photo in another gallery which has that next date it
will return that photo instead of the next one in the gallery.

In my view there are a number of things I could do but I would like to
hear from you which is best...

First of all, if possible can I overwrite the get_next_by_FOO()
function so it checks that the gallery is the same, but how?

Second, I could create a page function in my Photo model as such:

    def page(self):
            photo_list = [x for x in self.gallery.photo_set.all()]
            ind = photo_list.index(self)
            return ind + 1

And create a new template tag 'get_next_by_page' which checks for the
page/index.

Finally, in the template, which is fed with and object_list, I could
also try to go back in the for loop (again, don't know how) and just
get the previous/next objects in the list like so:

    {% for photo in object_list %}
        {% if has_next %}
            {# nextPhoto is object_list[currentCounter + 1 ] ? #}
        {% endif %}
    {% endfor %}

I hope someone can help me. Thanks in advance. Roderik


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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