I want to use get_model()
to avoid cyclic imports in my models, but I get name 'get_model' is not defined
error. I read that get_model()
was depreciated in 1.8 and apparently is not present in 1.9. What is the equivalent call? Or is there another way to avoid cyclic imports in two models.py
files?
django.db.models.loading.get_model()
has been removed in django 1.9.
You are supposed to use django.apps
instead.
>>> from django.apps import apps >>> apps.get_model('shop', 'Product') <class 'shop.models.Product'> >>>
Django docs reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With