Nevermind. Apparently, my reference to a class attribute in my __repr__
was messing stuff up. I guess you can't do that....
Jeremy Jones wrote:
I have the following two classes as part of my overall model:
class CustomerOrder(meta.Model):
customer = meta.ForeignKey(CustomerAddress)
order_date = meta.DateTimeField(auto_now_add=True)
order_completed = meta.BooleanField()
order_fulfilled = meta.BooleanField()
fulfilled_date = meta.DateTimeField(blank=True)
products_total = meta.FloatField(max_digits=10, decimal_places=2,
blank=True)
shipping = meta.FloatField(max_digits=10, decimal_places=2,
blank=True)
paid = meta.BooleanField()
def __repr__(self):
return str(self.order_date)
class META:
admin = meta.Admin()
class ItemGroup(meta.Model):
product_group = meta.ForeignKey(ProductGroup)
customer_order = meta.ForeignKey(CustomerOrder)
def __repr__(self):
return self.product_group.name
class META:
admin = meta.Admin()
When I try to do:
customer_order_object.add_itemgroup(product_group=product_group_object)
(where customer_order_object and product_group_object are instances of
those respective classes which I've either just created or retrieved
through querying for them), I get """AttributeError: 'ItemGroup' object
has no attribute 'product_group'""". I get the same thing if I try to
do customer_order_object,get_itemgroup_list(). Why would I be getting
an attribute error saying that ItemGroup doesn't have an attribute of
product_group when I set that as a foreign key on my ItemGroup class?
- jmj