Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using django.utils.importlib which is depricated in Django 1.9 #13

Open
pjcuadra opened this issue Jan 28, 2016 · 3 comments
Open

Using django.utils.importlib which is depricated in Django 1.9 #13

pjcuadra opened this issue Jan 28, 2016 · 3 comments

Comments

@pjcuadra
Copy link

I can get it to work with Django 1.9. The first issue I encountered was this one. According to https://docs.djangoproject.com/en/1.9/internals/deprecation/. The django.utils.importlib you are importing in utils.py is depricated.

@belgacea
Copy link

Modifying utils.py file from :
from django.utils import importlib, timezone
to :
from django.utils import timezone
import importlib
throws an AppRegistryNotReady exception when trying to runserver or migrate.

Full trace :

Unhandled exception in thread started by <function check_errors..wrapper at 0x000001A1E3F67840>
Traceback (most recent call last):
File "virtualenv_dir\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(_args, *kwargs)
File "virtualenv_dir\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "virtualenv_dir\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
six.reraise(exception)
File "virtualenv_dir\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "virtualenv_dir\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(args, **kwargs)
File "virtualenv_dir\lib\site-packages\django__init
.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "virtualenv_dir\lib\site-packages\django\apps\registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "virtualenv_dir\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "virtualenv_dir\lib\importlib__init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in load_unlocked
File "", line 662, in exec_module
File "", line 222, in call_with_frames_removed
File "virtualenv_dir\lib\site-packages\periodically__init
.py", line 3, in
from .utils import get_scheduler_backend_class
File "virtualenv_dir\lib\site-packages\periodically\utils.py", line 4, in
from .models import ExecutionRecord
File "virtualenv_dir\lib\site-packages\periodically\models.py", line 14, in
class ExecutionRecord(models.Model):
File "virtualenv_dir\lib\site-packages\django\db\models\base.py", line 94, in new
app_config = apps.get_containing_app_config(module)
File "virtualenv_dir\lib\site-packages\django\apps\registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "virtualenv_dir\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

@kolsiA
Copy link

kolsiA commented Mar 28, 2019

@belgacea
on utils.py, you need to declare the "from .models import ExecutionRecord" inside "get_scheduled_time"

@jgtvares
Copy link

@kolsiA
Doing that raises ModuleNotFoundError: No module named 'django.utils.importlib'
And I'm not even importing importlib from django.utils, just import importlib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants