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
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)
>
>
>
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
> 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
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
5 matches
Mail list logo