views:

169

answers:

1

Hello.

I want to create an order form to buy multiple things in this sort of structure:

Business Data 1
---Product A
---Product B
Business Data 2
---Product A

That is, I want to sell products A,B, but before this is done I need additional aggregate data to be in the 'Business Data' object. That is:

Business 1: Joe's Plumbing, located at ... ... ...
---Product A, standard ad appearing in category 3, with text "awesome plumbing"
---Product B, cooler ad appearing in category 9, with text "cheap plumbing"
Business 2: Joe's Burgers, located at ... ... ...
---Product A, standard ad appearing in category 4, with text "zzz"

or, from a model level, more like:

class Business(models.Model):
    name = models.CharField(max_length=255)
    address = models.MagicAddressField()

class Ad(models.Model):
    category = models.ForeignKey(Category)
    text = models.CharField(max_length=255)
    business = models.ForeignKey(Business)

Now, instead of reimplementing an entire shopping cart backend, I'm pretty sure I want to use Satchmo. However, i'm having trouble wrapping my head around this sort of thing.

Satchmo appears to have multiple options for Products, but they're all "flat". That is, while I could easily get Satchmo to allow the end user to buy Product A and Product B, the db shows no connection to Business 1, and things like the business name would have to be repeated in both product A and B.

I think I can probably get around this with my own views / templates, if only I can get the final "product instance" that satchmo is selling during an order to have a foreign key to the Business table i'll create myself. In other words, I want to make the Ad model a satchmo custom product model - I think...

But If I just change Ad to:

class Ad(Product):
    objects = ProductManager()

    category = models.ForeignKey(Category)
    text = models.CharField(max_length=255)
    business = models.ForeignKey(Business)

Isn't this the wrong semantics? Doesn't that mean that "this product type is associated with business x", not "when you buy this, the product's instance will be pointing to business x"?

I'm pretty confused here :-/

+1  A: 

I want to answer your question but I'm not terribly sure what exactly it is. Could you clarify your question?

Mike Sandford