Comments (10)
The documentation seems not to be up-to-date anymore. Sorry about that.
Could you try the following? :
from shop.models.defaults.bases import BaseCart
class MyCart(BaseCart):
class Meta(object):
pass
And add this to you SHOP_CART_MODEL ?
Notice - this is similar to your second example, but in your second example MyCart still extends "Cart" - Not BaseCart.
Let me know if this helps. Once you confirm it works I'll update the docs.
from django-shop.
Thank you for fast reply
But it does not help me and raise same
django.core.exceptions.ImproperlyConfigured: Backend module "apps.carts.models" does not define a "MyCart" class.
In my second example i mean just this, but i don't use copy-paste and rewrite first example :)
So, i still need help. In case of enmergency i have monkey patching solution, but i hate it and always try to find technological solution
from django-shop.
Ok, I'll investigate on my side how I do it on the sites that use this trick.
Sorry about this. I'll get back to you ASAP.
from django-shop.
Hi again.
I had a look at the shop where we use the model injection, and discovered that we actually rewrote models - not extended them. So a semi-ugly fix is to make your Cart extend models.Model, and re implement the methods on there. This is ugly because obviously it's not DRY, but it at least does the job until a better fix is discovered (I'll spend some of my time investigating further).
Thanks
from django-shop.
I think eged is better describe this problem it issue #96
In addition he suggested solutions.
Is there any progress?
from django-shop.
I was able to workaround the problem by modifying get_model_string() in shop.util.loader. See commit 9d63a63
Not sure how much viable solution it is generally, but works for me so far.
from django-shop.
Same issue applies to custom Order models as well.
UPDATE: I am not sure if it really applies to custom Order models, would have to test it further
from django-shop.
eged, i was trying your commit and it does not work for me.
when i try syncdb i was take
Error: One or more models did not validate:
shop.cartitem: 'cart' has a relation with model apps.customshop.cart.models.Cart, which has either not been installed or is abstract.
in this case i use my model based to CartBase from defaults models. of course abstact was False
There is one case when i take a profit
I was created Cart model identical to CartBase with minor changes - app_label and abstract and it works!
But it duplicated huge chunk of code and DRY was lost :(
from django-shop.
Hi, my hack is vulnerable to the file structure in which the extended model is defined. It works best in simple case when extended model is in the form: customapp.models.Cart, but if you have different structure you can avoid the validation error like above by inserting the correct app_label to extended model Meta options.
from django-shop.
I believe this was solved in the circular import fix #125
from django-shop.
Related Issues (20)
- Overridden AdminSite
- Supporting filter_backends option for ProductRetrieveView
- OperationalError at / no such table: cms_urlconfrevision HOT 1
- "Can not add/subtract money in different currencies." HOT 4
- Decoupling Django Shop from Django CMS HOT 11
- Is there a way to checkout without billing or shipping addresses? HOT 1
- Bug with endless scrolling when there are has offset HOT 6
- Missing phonenumber option in link plugin
- Cannot install: No module named weakref
- Clear Cart functionality (aka delete all items in Cart at once)
- pipenv run ./manage.py initialize_shop_demo [ERROR] HOT 2
- Django 3.2 HOT 2
- filterChanged() not working
- Is project still active? HOT 2
- An admin for model "User" has to be registered to be referenced by FolderAdmin.autocomplete_fields HOT 2
- Multi-Tenancy Doc is not finished
- error while installation HOT 1
- Install error while parsing `--sequential` requirements HOT 2
- Problem with css variables HOT 2
- Django-shop elasticsearch bug "Unexpected queryset model" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-shop.