It's so simple, thanks alot for the speedy replies !
On Oct 13, 4:31 pm, Héctor García <hecto...@gmail.com> wrote:
> Once you have passed your links queryset to the template context, you
> can just do:
>
> {% for saved_link in links %}
> {{ saved_link.link.title }}
> {{ saved_link.link.pub_date }}
> {% endfor %}
>
> (embed your HTML dress and you're done)
>
> Cheers!
>
> Hector Garcia - Web developer, musician
> NomadBlue URI:http://nomadblue.com/
>
> On Tue, Oct 13, 2009 at 4:23 PM, grimmus <graham.col...@gmail.com> wrote:
>
> > Hi,
>
> > I have a model called Link that allows the user to save a URL with a
> > title and description. The website i am making is full of Links users
> > have added (like a bookmarking service)
>
> > class Link(models.Model):
> > user = models.ForeignKey(User)
> > title = models.CharField(max_length=200)
> > link = models.URLField(verify_exists=True)
> > pub_date = models.DateTimeField('Date Published')
>
> > Other users can save their favourite links that they see on the site.
> > For this i created a SaveLink model
>
> > class SaveLink(models.Model):
> > user = models.ForeignKey(User)
> > link = models.ForeignKey(Link)
> > save_date = models.DateTimeField(auto_now=True)
>
> > On the users profile page i want to list the links they added as their
> > favourites, so i need the user and link fields from the SaveLink model
> > and i also want to show the title and pub_date fields from the Link
> > model.
>
> > Currently my view looks like
>
> > links = SaveLink.objects.filter(user=request.user).order_by('-
> > save_date')
>
> > But how can i access fields from both the SaveLink model and Link
> > model in the queryset ?
>
> > Sorry for the noob question !!
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---