wagtail-longclaw/longclaw/utils.py

15 wiersze
423 B
Python
Czysty Zwykły widok Historia

2017-04-02 09:14:20 +00:00
from django.apps import apps
from django.utils.module_loading import import_string
from longclaw.settings import PRODUCT_VARIANT_MODEL, PAYMENT_GATEWAY
2017-04-02 09:14:20 +00:00
GATEWAY = import_string(PAYMENT_GATEWAY)()
2017-04-02 09:14:20 +00:00
ProductVariant = apps.get_model(*PRODUCT_VARIANT_MODEL.split('.'))
def maybe_get_product_model():
try:
field = ProductVariant._meta.get_field('product')
return field.related_model
except:
pass