In one of my django tests, I use django.utils.importlib.import_module
similarly to how it is used here.
On upgrading to django 1.8, I get a deprecation warning
test_views.py:20: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
from django.utils.importlib import import_module
Is the recommended practice now to use import_module
from importlib
in the standard library (which seems to work fine)? Or is the recommended practice to avoid using import_module
entirely?
Based on the documentation (found by looking at the django deprecation timeline for 1.9 and following the link), your first suggestion seems to be correct: developers should use the standard importlib
that is part of the standard library.
Yes, django.utils.importlib.import_module
is effectively the same thing as importlib.import_module
. As long as you're not targeting a version of Python before 2.7, it is okay to just use importlib.import_module
.
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