On Mar 11, 2010, at 11:56 AM, [email protected] wrote:
I have the following model:
1 class MyOrderItem(models.Model):
2 orderitem = models.ForeignKey(OrderItem, null=True,
blank=True)
3 # other fields
4
5 def save(self, *args, **kwargs):
6 if self.orderitem and self.orderitem.order:
7 orderitems =
MyOrderItem.objects.filter(orderitem__order = self.orderitem.order)
8 # ...
9 super(MyOrderItem, self).save(*args, **kwargs)
If I execute this from `python manage.py shell`, it works fine, and
orderitems (line 7) is a list with 3 items. But if I execute it in a
runserver-session, self is omitted from the list, and orderitems is
a list with 2 items.
It looks like self.orderitem hadn't been stored in the database yet.
Moving line 9 to line 6 solves the problem.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.