On Tue, Jan 25, 2011 at 11:41 AM, Jaroslav Dobrek <jaroslav.dob...@gmail.com> wrote: >>> What happens ? > > I get this error message when I run manage.py syncdb: > > AttributeError: 'ForeignKey' object has no attribute 'producer' > >>> And what did you expect to happen ? > > I want the 'country_of_origin' of cars to be the string that is stored > in their producer's 'country_of_origin': > > class CarProducer(models.Model): > country_of_origin = models.CharField(max_length=200) > > > class Car(models.Model): > producer = models.ForeignKey(CarProducer) > country_of_origin = producer.country_of_origin >
class Car(models.Model): producer = models.ForeignKey(CarProducer) @property def country_of_origin(self): return self.producer.country_of_origin Cheers Tom -- 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.