pawamoy/django-suit-dashboard

Apps aren't loaded yet error - trying to replicate wiki example

Closed this issue · 5 comments

Hello,

I'm trying to replicate this example using Django 1.10.6 and Suit 0.2.25 (and also the official installation information for Suit Dashboard. My INSTALLED_APPS section of my settings file is as follows:
`

SUIT = True
#SUIT = False

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dashboard',
'suit_dashboard'
]

if SUIT: # add suit and replace admin with SimpleAdminConfig
INSTALLED_APPS = [
'suit',
'django.contrib.admin.apps.SimpleAdminConfig'
] + INSTALLED_APPS[1:]
`

When I attempt to run the application within Pycharm I get the following trace:

Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace instance at 0x10b6f37a0>
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_monkey.py", line 589, in __call__
    return self.original_func(*self.args, **self.kwargs)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/Users/mferguson/.pyenv/versions/2.7.12/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/suit_dashboard/__init__.py", line 11, in <module>
    from .layout import Box, Column, Grid, Row
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/suit_dashboard/layout.py", line 14, in <module>
    from .widgets import Widget
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/suit_dashboard/widgets.py", line 16, in <module>
    from .views import PartialResponse
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/suit_dashboard/views.py", line 14, in <module>
    from braces.views import AjaxResponseMixin, JSONResponseMixin
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/braces/views/__init__.py", line 3, in <module>
    from ._access import (
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/braces/views/_access.py", line 7, in <module>
    from django.contrib.auth.views import redirect_to_login, logout_then_login
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/contrib/auth/views.py", line 11, in <module>
    from django.contrib.auth.forms import (
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 12, in <module>
    from django.contrib.auth.models import User
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
    class AbstractBaseUser(models.Model):
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/db/models/base.py", line 105, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/site-packages/django/apps/registry.py", line 237, in get_containing_app_config
    self.check_apps_ready()
  File "/Users/mferguson/.pyenv/versions/2.7.12/envs/hammer-dash-2712/lib/python2.7/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.

If I remove suit_dashboard from settings the app runs without issue. I'm also using Python 2.7.12. Is there a dependency on Python 3 or is this an INSTALLED_APPS ordering issue? I've tried different variations with no luck.

Thanks for any insight you can provide in resolving this issue!

Best regards,

Mark

Update: I was using django-suit-dashboard==2.0.1

If I downgrade to django-suit-dashboard==2.0.0 I no longer have the above issue.

Hopefully this will help track down the issue.

Mark

Hi, thanks for the report!

Yes indeed the issue comes from 2.0.1, it's because 2.0.1 imports contents in __init__, importing django-braces, itself importing things from django that try to load models...

I already fixed that by removing the PartialResponse class definition in views. If needed, it's a very simple class that can be written by the user, I took it from an example in django-braces documentation.

I will push a release with this fix today.

Oh, in fact don't use the wiki, the official doc is on readthedocs now (http://django-suit-dashboard.readthedocs.io/en/latest/index.html). I will remove the wiki.

I pushed version 2.0.2, let me know if it works for you.

Thanks for the quick update. 2.0.2 is working as desired now.

As for the wiki going away I was wondering if you would be willing to create a repo for a full working example? You've got some great code fragments for things like realtime, highchart integration, etc. and I really struggled to get them working in an actual project. I'm a long time Python developer but still pretty green with Django but a working example would be much appreciated.

Thanks again! This is a great project.

Thank you ❤️

If you struggled getting examples to work then a demo project would be a very good idea indeed.
I'll work on that and create a related issue 😃 (closing this one though, since it's resolved)