barseghyanartur / django-dash

Customisable, modular dashboard application framework for Django.
https://pypi.python.org/pypi/django-dash
383 stars 85 forks source link

django-dash doesn't work with Django 1.7 #6

Closed tgs closed 9 years ago

tgs commented 9 years ago

The main issue I found is that it fails during Django's setup. In 1.7, apparently, one is not supposed to call get_user_model() in module-level code. Here is a backtrace:

  File "/home/smithtg/src/crm-dashboard/env/lib/python3.3/site-packages/dash/models.py", line 20, in <module>
    from dash.compat import User
  File "/home/smithtg/src/crm-dashboard/env/lib/python3.3/site-packages/dash/compat.py", line 13, in <module>
    User = get_user_model()
  File "/home/smithtg/src/crm-dashboard/env/lib/python3.3/site-packages/django/contrib/auth/__init__.py", line 136, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "/home/smithtg/src/crm-dashboard/env/lib/python3.3/site-packages/django/apps/registry.py", line 199, in get_model
    self.check_models_ready()
  File "/home/smithtg/src/crm-dashboard/env/lib/python3.3/site-packages/django/apps/registry.py", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

I worked around this by changing src/dash/compat.py to read:

__all__ = ('User',)

from django.conf import settings
User = settings.AUTH_USER_MODEL

I imagine that this breaks some old versions of Django, but I haven't tested. If you're interested in a pull request, I might have time to try it out.

barseghyanartur commented 9 years ago

@tgs

Hey, thanks much for reporting this.

I've started to work on Django 1.7 compatibility. So far, it does seem to work with some tiny tricks. I need to spend some more time on it though, in order to prepare a new release.

I'll post updates on the issue right here.

barseghyanartur commented 9 years ago

@tgs

This should be properly documented (a TODO), but master branch does work for me in Django 1.7.

See the following files:

No apps that are incompatible with Django 1.7 should be listed in the settings.py.

What for the example project, that comes with django-dash, the only difference is that django-registration has been replaced with django-registration-redux, which works fine with Django 1.7 as well.

No release has been made yet, since there's some work to do still, but that's what works already.

tgs commented 9 years ago

Thank you for the quickness of your response! I'll try out your changes today.

barseghyanartur commented 9 years ago

@tgs

Hey, I was wondering if it worked for you. Did it?

barseghyanartur commented 9 years ago

@tgs

Hey, I've just released a new version 0.4.8 (PyPI updated too). All automated tests and tests that I have made with 3-rd party apps passed. With several dependencies updated and tiny changes to settings, it works just fine.

I'm closing this issue. If you get any problems regarding the 1.7 support, please open a new issue.