lazybird / django-carton

A simple and lightweight application for shopping carts and wish lists.
Other
274 stars 101 forks source link

Support for multiple models #23

Open Matt-Deacalion opened 8 years ago

Matt-Deacalion commented 8 years ago

I would like to have two carts on a single web site, which is easy enough - but I would like each one to work on a different model. I think the best way would be to add an optional model kwarg to the Cart __init__ method, then have get_product_model use the specified model if it exists, otherwise it falls back to the current behaviour.

Is this something done before? if it's useful, could I do a pull request for it?

Matt-Deacalion commented 8 years ago

I went another way with this. I made Django Carton model agnostic, so it doesn't need to know in advance what product model it's dealing with. My real world use is that my cart needs to be able to deal with both Merchandise and Ticket models.

The code is here: https://github.com/Matt-Deacalion/django-carton/commit/1e17a0f0daa1f01c7d911505047c4e3ef3095eea

If you're interested in accepting it upstream I'll clean it up and do a pull request. The changes are all backwards compatible.

olivierdalang commented 7 years ago

Hi !

I'd love this too. Wouldn't it be quite easy using the content types framework ?