Hi Martin! Thanks so much for the quick reply, I really appreciate your help. :)

On Tue, Jun 7, 2011 at 1:48 AM, Martin <martin.brochh...@googlemail.com> wrote:
> Why not create a Manager?
> Give it a method foo1_related() which then returns something like
> self.foo1_set.filter( your filters ) and a similar method foo2_related (if
> needed).
> You can then call A.foo1_related() and get what you need.

That sounds good to me! I will definitely head that route.

The primary thing I like about select_related is that I can do this on
the template level (for example):

{% with object.file1.select_related as foo %}
...
{% endwith %}

Where the context of the field has already been accounted for.

This might sound silly, my goal is to:

1. Get the first related file in the related files M2M
2. Get everything but the first file in the related files M2M

For #1, I could use {% with object.file1.select_related|first as foo
%}... and for #2 I could say {% for ... %}{% if not forloop.first
%}... But I thought it would be nice to have a couple of functions
that I could call, from the template, that behaved like select_related
and worked on either file1/file2 without having to hard-code
file1/file2 into the methods.

But I think I just have very little experience with
managers/django/python, and I am betting that your suggestion of using
managers will end up being the optimal route for this situation. :)

Thanks for the kick, I really appreciate it!!!

Have an awesome day.

Cheers,
Micky

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to