-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to configure #95
Comments
The documentation seems not to be up-to-date anymore. Sorry about that. Could you try the following? :
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. |
Thank you for fast reply But it does not help me and raise same 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 |
Ok, I'll investigate on my side how I do it on the sites that use this trick. |
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 |
I think eged is better describe this problem it issue #96 |
I was able to workaround the problem by modifying get_model_string() in shop.util.loader. See commit 9d63a63 |
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 |
eged, i was trying your commit and it does not work for me. 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 |
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. |
I believe this was solved in the circular import fix #125 |
Guys, i have some problem with configuring django-shop app
i set SHOP_CART_MODEL to 'apps.carts.models.MyCart'
and try two ways:
MyCart model based on Cart (like in docs on http://readthedocs.org/docs/django-shop/en/latest/howto/how-to-extend-django-shop-models.html
from shop.models import Cart
class MyCart(Cart):
class Meta(object):
pass
this raise:
django.core.exceptions.ImproperlyConfigured: Error importing backend apps.carts.models: "cannot import name Cart". Check your SHOP_CART_MODEL setting
and MyCart model based on BaseCart
from shop.models.defaults.bases import Cart
class MyCart(Cart):
class Meta(object):
pass
it raise:
django.core.exceptions.ImproperlyConfigured: Backend module "apps.carts.models" does not define a "MyCart" class.
it takes me much time of trying to fix it. guys, please, help)
The text was updated successfully, but these errors were encountered: