On Apr 1, 6:43 am, Denis <deuns.marti...@gmail.com> wrote:
> I am developing a store using Satchmo, and I want the ability to save
> quotes; that's snapshots of the current cart, and I want to store the
> history of all the quotes in the database. My current models look like
> this:
>
> class QuoteItem(models.Model, Product):
>     quantity = models.PositiveIntegerField(_('Quantity'))
>     price_incl_vat = models.DecimalField(_("Price incl. VAT"),
> max_digits=10, decimal_places=2)
>
> class Quote(models.Model):
>     items = models.ManyToManyField('QuoteItem')
>
> In Django my inherited Product class is represented as a foreign key
> in the QuoteItem table. The problem is that the product price is
> subject to change in the future, but the Quote shouldn't change.
> I want a copy of the product attributes in QuoteItem, instead of a
> foreign key.

Yes, that's the right way to approach this problem.

> Is there a clean way to do, or do I have to copy all the attributes
> here manually?

You could serialize your product instance into a TextField in
QuoteItem:

from django.core import serializers
serialized_product = serializers.serialize("json", [product_instance])

-Rajesh D

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

Reply via email to