Tuesday, January 25, 2011

Re: method of method

>> 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

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment