products/models.py: add UPC class
This commit is contained in:
@ -1,14 +1,20 @@
|
||||
from products.models import Product, SeasonRegionMaterial
|
||||
from products.models import Product, SeasonRegionMaterial, UPC
|
||||
|
||||
|
||||
class ProductDBRouter(object):
|
||||
|
||||
def is_product_class(self, model):
|
||||
return \
|
||||
model == Product or \
|
||||
model == SeasonRegionMaterial or \
|
||||
model == UPC
|
||||
|
||||
def db_for_read(self, model, **hints):
|
||||
if model == Product or model == SeasonRegionMaterial:
|
||||
if self.is_product_class(model):
|
||||
return 'products'
|
||||
return None
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
if model == Product or model == SeasonRegionMaterial:
|
||||
if self.is_product_class(model):
|
||||
return 'products'
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user