So what I've not any complain for satchmo, the fact is that is not the ideal solution for some cases as some small shops with few options.
With that said, this post is to announce the release of a new project that could help some people to do simple web shops in a very simple way. This project is django-cart.
While django-cart already existed, it was an unfinished (and unmaintained) project by Eric Woundenberg, to whom I'm very thankful for letting reuse it's project, and avoid confusion.
So, what's django-cart. Django Cart is basically a django application that provides a Cart class, with add/remove/update and get methods to be used for storing products. The products model isn't included in the application, so you can define your products with the fields you need. Then you just need something like...
product_to_add = MyProductModel.objects.get(id=whatever)
cart = Cart(request)
cart.add(product_to_add, product_to_add.price)
and your product will be saved on the database, on a session based cart. Getting the content of the cart is as easy as itering the cart instance.
And basically that's it. More information is available on the project page. Just note that the current version of the application is unstable, and hasn't been tested enough, so feel free to use it, but consider that you'll have to test it by yourself and report/fix some bugs.
I hope all you like it!
thank you! very useful
ReplyDeletepython manage.py syncdb doesn't work.
ReplyDelete_mysql_exceptions.OperationalError: (1054, "Unknown column 'cart_cart.creation_date' in 'order clause'")
Once I commented out the following line syncdb worked:
ReplyDeleteordering = ('-creation_date',)
(from models.py Cart)
Can't figure out why you got that error... Line looks to be ok, and it's working for me.
ReplyDeleteDoes the column exist on database? That error usually happens when your model has a column that doesn't exist in database...
The database doesn't exist until I run syncdb. But syncdb fails because of that line. Interesting. Maybe its a mysql problem, are you using mysql?
ReplyDeleteI've just tried it on sqlite for now, I'll try on mysql and let you know.
ReplyDeleteHola Marc, se que hablas español porque vi tu profile en linked. Soy muy novato en esto de django y he implementado django-cart sin ningun problema, es solo que tengo unas dudas porque como te mencione anteriormente, soy muy muy newbie aqui. Duda: como haria para cambiar el ItemAlreadyExists e interpretarlo como incrementarle al quantity actual de ese Item?, te lo pregunto porque lo que puedo entender de cart.py es que tiene los metodos CRUD pero no estan totalmente implementados. gracias hermano (desde colombia)
ReplyDeleteHola Luis,
ReplyDeletesi entiendo bien lo que me preguntas, lo que quieres es que si insertas un producto más de una vez, en lugar de fallar, incremente el contador... yo no cambiaría django-cart, yo haría algo como:
try:
cart.add(...)
except ItemAlreadyExists:
cart.update(...)
Saludos desde Catalunya amigo colombiano! :)
Marc
Just as an FYI for newer Python devs, to catch the ItemAlreadyExists and ItemDoesNotExist exceptions remember to import them into your views before you try to use them.
ReplyDeleteHello!
ReplyDeleteIs this project still maintained?
I was looking at Satchmo & LFS, but both seems way too complicated for our needs (small company 'selling' only services), so I'm curious if the project is still alive?
Sincerely,
Gour
No, really. Actually the code has few things missing, and a known bug.
ReplyDeleteBut I would use it anyway, and you'll fix all this stuff easily, and it'll work much better than any of this projects, I think.
And if you do so, it'll be great if you can contribute your changes back to the project.
Thank you!
How does one view the items of the cart in Django Admin, and also on a template?
ReplyDelete