Daniel,
thanks a lot, it works perfectly

Paolo

On Nov 17, 8:19 pm, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Nov 17, 4:42 pm, Paolo Corti <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
> > maybe this is trivial, but i can't find a way to get it (and from what
> > i can see it seems not possible):
>
> > my model:
>
> > class Project(models.Model):
> >         name = models.CharField('name', max_length=255)
> >         ....
> >         #relationship
> >         projectowner = models.ForeignKey(Person)
>
> > in admin.py:
>
> > class ProjectAdmin(admin.ModelAdmin):
> >         model = Project
> >         list_display = ['name', ..., 'projectowner']
> >         list_display_links = ['name']
> >         list_filter = ['name', 'projectowner']
>
> > list_display_links will put a link at the 'name' field to the
> > Project's page, like this 
> > one:http://localhost:8000/admin/projects/project/1/
>
> > is there a way to the the same result for the foreign key?
>
> > I would like that at the 'projectowner' field there would be a link
> > like this one:http://localhost:8000/admin/projects/person/2/
>
> > thanks!
>
> Your best bet would be to define a method on the Project model that
> returns a snippet of HTML with the link and text. You need to set
> allow_tags=True.
>
> def projectowner_link(self):
>     return u'<a href="/admin/projects/person/%s/">%s</a>' %
> (self.projectowner.id, self.projectowner.name)
> projectowner_link.allow_tags = True
>
> list_display = ['name', ..., 'projectowner_link']
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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