Re: check if user has already saved link

2009-10-14 Thread grimmus
Thanks so much to you both, it's all working great :-) On Oct 14, 3:27 pm, "Michael P. Jung" wrote: > > return user.savelink_set.objects.filter(link=object).count() (...) > > The error i get now is  : Caught an exception while rendering: > > 'RelatedManager' object has no attribute 'objects' > >

Re: check if user has already saved link

2009-10-14 Thread Michael P. Jung
> return user.savelink_set.objects.filter(link=object).count() (...) > The error i get now is : Caught an exception while rendering: > 'RelatedManager' object has no attribute 'objects' user.savelink_set is already a Manager and does not have an attribute "objects". Just write "user.savelink_s

Re: check if user has already saved link

2009-10-14 Thread grimmus
ok, now it looks like from django import template register = template.Library() @register.filter("has_saved_link") def has_saved_link(user, object): return user.savelink_set.objects.filter(link=object).count() and then in the template it's like {% if user.is_authenticated and not user|has_

Re: check if user has already saved link

2009-10-14 Thread Daniel Roseman
On Oct 14, 1:36 pm, grimmus wrote: > Thanks for your reply. Here's what i did so far > > i created a file called has_saved_link.py in my app's templatetags > folder: > > from django.template import Library, Node > from django.db.models import get_model > > register = Library() > > def has_saved_l

Re: check if user has already saved link

2009-10-14 Thread grimmus
Thanks for your reply. Here's what i did so far i created a file called has_saved_link.py in my app's templatetags folder: from django.template import Library, Node from django.db.models import get_model register = Library() def has_saved_link(user, object): return user.savedlink_set.objec

Re: check if user has already saved link

2009-10-14 Thread Daniel Roseman
On Oct 14, 10:38 am, grimmus wrote: > Hi, > > I have 2 Models, Link and SaveLink. > > Link allows URL's with title's and descripions to be added to the > site. > SaveLink allows the logged in user to save their favourite links. > > When i output all the links on the page i would like to check if

check if user has already saved link

2009-10-14 Thread grimmus
Hi, I have 2 Models, Link and SaveLink. Link allows URL's with title's and descripions to be added to the site. SaveLink allows the logged in user to save their favourite links. When i output all the links on the page i would like to check if the active user has already saved the current link.