Thanks Stuart,
I'll try going this route from the site and source:
(So far it validates and I can add Product in the Admin)
from django.db import models
from django.utils.translation import ugettext_lazy as _
from product.models import Product
SATCHMO_PRODUCT=True
def get_product_types():
"""
Returns a tuple of all product subtypes this app adds
"""
return ('Kit', 'Package', )
class Package(models.Model):
product = models.OneToOneField(Product, verbose_name=_('Product'),
primary_key=True)
kits = models.ManyToManyField('Kit', blank=True,
related_name='package_kits')
items = models.ManyToManyField(Product, blank=True,
related_name='package_items')
. . .
class Kit(models.Model):
product = models.OneToOneField(Product, verbose_name=_('Product'),
primary_key=True)
contents = models.ManyToManyField(Product, blank=True,
related_name='kit_contents')
. . .
If anyone has any suggestions from here let me know:)
On Jan 7, 12:29 pm, Stuart Laughlin <[email protected]> wrote:
> This is essentially a kit, no?
>
> I think it would be better to say that a kit cannot contain another
> kit, otherwise it's more complicated.
>
> If a kit can contain products, but not other kits, maybe you could
> create a new custom Product (called Kit) that contains refs to other
> Products.
>
> from product.models import Product
>
> class Kit(Product):
> products = models.ManyToManyField(Product)
>
> If a kit can contain other kits, you probably need ManyToManyField("self").
>
> Maybe I'm barking up the wrong tree, but it might be worth a try.
>
> --Stuart
>
> On Fri, Jan 7, 2011 at 11:20 AM, hunter <[email protected]> wrote:
> > Hi!
>
> > New to Satchmo but not Django, and was wondering what the best way in
> > Satchmo might be to create a product or package that has it's own
> > instance as a Product but is also comprised of more than one other
> > Product?
> > Something like:
>
> > Product1 = [Product]
> > Product2 = [Product]
> > Product3 = [Combined(Product1, Product2)]
> > Product4 = [Product]
> > Product5 = [Combined(Product3, Product4)]
>
> > I suppose this implements a recursive relation. Any help pointing me
> > down the right path would be appreciated!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Satchmo 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
> > athttp://groups.google.com/group/satchmo-users?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Satchmo 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/satchmo-users?hl=en.