Thanks! Problem solved, here's how to do it:
class QuoteItemManager(models.Manager):
def from_product(self, product):
i = QuoteItem(current_product=product)
i.product_serialized = serializers.serialize('json',
Product.objects.filter(id=product.id))
try:
i.productinfo_serialized = serializers.serialize('json',
product.productinfo_set.all())
except ProductInfo.DoesNotExist:
i.productinfo_serialized = ''
return i
def to_product(self, quoteitem):
p = serializers.deserialize('json',
quoteitem.product_serialized).next().object
if quoteitem.productinfo_serialized != '':
p.productinfo_set.add(serializers.deserialize('json',
quoteitem.productinfo_serialized).next().object)
return p
QuoteItem.objects = QuoteItemManager()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---