Sorry guys, yes, it works specifying person.field1.name (i was using wrongly person.field1_id.name). Thank you Nuno and Daniel.
What about the "photos_set" value in the template? If I only want to get the first object of that set, how can i do to not iterate (with a 'for') the whole set? Remember this field is included in the person object already given. By now for example, I'm using: {% for p in person_list.object_list %} {% for img in p.fotos_set.all %} {% ifequal img.ordering 0 %} ..... But I don't want to iterate the whole "p.fotos_set.all". And I know I can not do filtering on a template (it's only presentation layer). Any advice is welcome, thanks again. Caio On Fri, May 7, 2010 at 7:45 AM, Daniel Roseman <dan...@roseman.org.uk> wrote: > On May 7, 10:53 am, caio <elc...@gmail.com> wrote: >> I have in my model something like this: >> >> class Person(models.Model): >> field1 = ForeignKey(City) >> field2 = models.TextField() >> field3 = ForeignKey(Type) >> photos = ImagingField() >> photos_set = generic.GenericRelation(Image) >> .... >> >> class City(models.Model): >> name = CharField() >> >> class Type(models.Model): >> value = CharField() >> >> Then I wanto to get in my template the value of Person.field1 but as >> "name" not the "id". The same with field3, I want the "value" not the >> "id". Maybe is a silly question, but doesn't work if I call >> Person.field1.name. >> >> Finally, I also want to use in my template the first value of the >> photos_set (in my previous email i refered to this as >> "my_custom_set"). But again, I can specify this field as values() >> method's parameter. >> >> Hope it explains better the situation. >> Thanks, >> Caio > > Something is definitely wrong here if you can't do > {{ person.field1.name }} in your template - assuming 'person' is an > instance of the Person model. That should definitely work. Please can > you post your view and template code showing this problem. > -- > 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-us...@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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.