bmentges / django-cart Goto Github PK
View Code? Open in Web Editor NEWDjango simple shopping cart solution, with tests :)
License: GNU Lesser General Public License v3.0
Django simple shopping cart solution, with tests :)
License: GNU Lesser General Public License v3.0
Hi,
I have 2 questions:
Cool library though.
/myapp/lib/python2.7/site-packages/cart/models.py:4:
RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and
will be removed in Django 1.9. Its contents have been moved to the fields, forms,
and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
Just to warn
Not a code issue, but the pypi version of this seems to be quite far behind this github repo, and thus doesn't support django 1.9.
Could you please do a new release and publish it to pypi?
Hi
Thank you for making this very useful and awesome library.
There are certain issues with this when we try to use it with python 3.* and django 2.*
We have found the fix for it, please apply these fixes so that we don't have to edit the two files everytime we install this.
* Bug fix with the django cart package
* Update file site-packages/cart/cart.py
At line 2
- *from . import models* in place of the import declaration.
and
*** Update file site-packages/cart/models.py
At line 27
replacement: cart = models.ForeignKey(Cart, verbose_name=_('cart'), on_delete=models.CASCADE)
At line 31
replacement: content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
type object 'QuerySet' has no attribute '_meta'
traceback:
kwargs['content_type'] = ContentType.objects.get_for_model(type(kwargs['product']))
I've been using django-cart for a basic app to sell physical products. It's simple and has worked okay for me so far.
I'm now working on adding Gift Card products where the price is chosen by the customer. The model this is based off is just a one-off model to change the name/description/etc. Price is chosen on the detail page.
This presents a problem as when I add a gift card to the cart for $50, and subsequently add another to the cart for $100, the cart sees both items as $100 instead of creating a separate line item for each.
Is there a way for me to prevent this item from grouping together without having to create model entries for all available prices?
This is an extract of the GPLv3 license:
"The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License."
I believe this cart library will be more useful if you change the license to LGPL. So can I ask you to change it or, if you don't like this idea, can I have your blessing to release a modified version of it under LGPL?
/myapp/lib/python2.7/site-packages/cart/models.py:26: RemovedInDjango19Warning:
Model class cart.models.Item doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded.
This will no longer be supported in Django 1.9.
class Item(models.Model):
Any suggested solution?
Seems that this project is sort of dead, several forks have been made .. even I started one https://github.com/angvp/django-changuito with some improvements I'd like to add some of my work there, but the process here seems to be slow, people who want to use a django-cart version with more features please give a try to django-changuito or let's make a deal with all the forks and make the next release of django-cart more complete and with more maintainers...
What do you think?
Running Python 3.4.3 and Django 1.9.5 (inside a virtualenv
environment), I get the following error when running python manage.py makemigrations
(I'm not using South):
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/caleb/projects/dev/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/caleb/projects/dev/lib/python3.4/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/caleb/projects/dev/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/caleb/projects/dev/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/caleb/projects/dev/lib/python3.4/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/caleb/projects/dev/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/caleb/projects/dev/lib/python3.4/site-packages/cart/__init__.py", line 1, in <module>
from cart import Cart, ItemAlreadyExists, ItemDoesNotExist
ImportError: cannot import name 'Cart'
The INSTALLED_APPS section of settings.py
looks like this:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cart',
]
django-cart was installed via pip install django-cart
There is a slight version mismatch between this repo and PyPI:
1.0.2
1.0.3
I added a git+
link to my pip dependencies because there were no recent versions of cart on PyPI back then. Now I am stuck with a package from git (which was 1.0.2) that I cannot upgrade to PyPI.
Hello there,
Installing django-cart using pip I've noticed that the pypi repo has an outdated version: cart.py.clear method is broken there, while here (github) the issue is already fixed.
Would you mind pushing an updated version?
Many thanks!
def update(self, product, quantity, unit_price=None):
try:
item = models.Item.objects.get(
cart=self.cart,
product=product,
)
except models.Item.DoesNotExist:
raise ItemDoesNotExist
may be
else: #ItemAlreadyExists
item.unit_price = unit_price
item.quantity = int(quantity)
item.save()
def new(self, request):
cart = models.Cart(creation_date=timezone.now())
cart.save()
request.session[CART_ID] = cart.id
return cart
Creating a new cart does not tie cart to a logged in user.
Initialization of CartProxy provides the necessary checks to see if user exists but the actual cart creation as shown above does not accommodate those options. Was this intentional or does the user have to implement it?
I am not sure if I AM the wrong part, but it seems that the cart version available here is very different the one available when we run pip install Django-cart. The issues that come when you install it seems to be fixed already here, but not for installation. I am trying to deploy my app to HEROKU and when it runs the installation of the requirements, it comes with all the errors. Am I doing something wrong??
Thank you
File "/usr/local/lib/python3.5/dist-packages/cart/cart.py", line 2, in
import models
ImportError: No module named 'models'
Hey, you may have done a model import the wrong way in cart.py , I'm using python3 and Django 1.9.7
Am encountering the following issue when trying to migrate:
(virtual) erick@rick:~/Documents/personal projects/gift a box$ ./manage.py migrate Traceback (most recent call last): File "./manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/django/core/management/__init__.py", line 347, in execute django.setup() File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate app_config.import_models() File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/cart/models.py", line 26, in <module> class Item(models.Model): File "/home/erick/Documents/personal projects/gift a box/virtual/lib/python3.6/site-packages/cart/models.py", line 27, in Item cart = models.ForeignKey(Cart, verbose_name=_('cart')) TypeError: __init__() missing 1 required positional argument: 'on_delete'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.