Tuesday, 15 January 2013

python - How to alter Fields in Django and Oscar -


I'm creating a web application with DJs-Oscars, and I want to create the required field for the user in the partner model.

My first approach was to override the "user" field in the partner model, but then I read that you

So, how can we change a field in the Oscars if we can not override it?

Thank you!

Docs are not very clear, but fortunately model overriding is well supported in the Oscars The way it has been engineered.

Instead of sub-classification and override the model oscar.apps.partner.Partner model, instead of overriding your own code, you will find your own myproject.partner Need to create an app

The point of attention is that all models of the Oscars have been implemented as an abstract model. Then the Oscars checks whether you have overridden any frame app, if the Oscars will not define a solid model from its essence. If you have overridden a frame app, though it will first try to load your concrete model, then fallback it on your own models for anyone.

See the document here:

Run it first:

  $ ./manage.py oscar_fork_app partner myproject /  < 

 #set.py Import from Get_core_apps # ... INSTALLED_APPS = [# all your non-Oscars] + get_core_apps (['myproject.partner'])  

and myproject /jsd.apps.partner.abstract_models Import from django.db import model to abstractpartner class partner (abstractpartner) from: / partner / models.py :

 : user = models.ForeignKey ( ... friendly here Imported from oscar.apps.partner.models *  

Since you have given them below, they are given the partner.StockRecord and partners The stock will come from the Oscars like normal, but this will automatically use your customized code everywhere.

If you want to use a level-loading device, then the Oscars use that you can (and confirm that your override is working):

 

No comments:

Post a Comment