Re: values() and GenericRelation

2010-05-07 Thread caio
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

Re: values() and GenericRelation

2010-05-07 Thread Daniel Roseman
On May 7, 10:53 am, caio 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) >     > >

Re: values() and GenericRelation

2010-05-07 Thread caio
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() cl

Re: values() and GenericRelation

2010-05-07 Thread Nuno Maltez
>  MyModel.objects.values('id', 'field1__name', 'field2', > 'field3__value', 'my_custom_set') ... > I could use all() result, but I must use the ForeingKey values of the > field1 and field3, so I don't know how to get its values if it not the > way I said before. > > How can I resolve this? I ca

values() and GenericRelation

2010-05-06 Thread caio
Hello, I need to put into a template some fields of my model, but not all the fields, it is better to specify which fields to pass. Then, I use something like: MyModel.objects.values('id', 'field1__name', 'field2', 'field3__value', 'my_custom_set') But, 'my_custom_field' is a GenericRelation fi