django-openinghours icon indicating copy to clipboard operation
django-openinghours copied to clipboard

Use get_model() from django.apps to fix incompatibility with django-q

Open jordanmkoncz opened this issue 7 years ago • 1 comments

So this is a bit of a weird issue. I have been using django-openinghours in a project for a while and not having any issues, and today I was working on integrating https://github.com/Koed00/django-q into the project.

For some reason, django-openinghours and django-q are not compatible with each other, and as soon as I add django_q to my INSTALLED_APPS in my project's settings.py, I get the following error when trying to load any page in the Django Admin:

Traceback:

File "/Users/jordan/Development/my_project/venv/lib/python3.5/site-packages/django/template/utils.py" in __getitem__
  65.             return self._engines[alias]

During handling of the above exception ('django'), another exception occurred:

File "/Users/jordan/Development/my_project/venv/lib/python3.5/site-packages/django/template/backends/django.py" in get_package_libraries
  126.             module = import_module(entry[1])

File "/Users/jordan/Development/my_project/venv/lib/python3.5/importlib/__init__.py" in import_module
  126.     return _bootstrap._gcd_import(name[level:], package, level)

File "/Users/jordan/Development/my_project/venv/lib/python3.5/site-packages/openinghours/templatetags/openinghours_tags.py" in <module>
  6. from openinghours import utils

File "/Users/jordan/Development/my_project/venv/lib/python3.5/site-packages/openinghours/utils.py" in <module>
  9. from compat import get_model

Exception Type: InvalidTemplateLibrary at /admin/login/
Exception Value: Invalid template library specified. ImportError raised when trying to load 'openinghours.templatetags.openinghours_tags': cannot import name 'get_model'

If I remove django_q from my INSTALLED_APPS, the error goes away and everything works fine again, but then I can't use django-q obviously, so I've managed to find another solution. If I update the django-openinghours code to use get_model() from django.apps instead of get_model() from compat, I no longer get this InvalidTemplateLibrary exception and both django-openinghours and django-q work correctly. I have created a fork of django-openinghours which has this fix, which you can see at https://github.com/jordanmkoncz/django-openinghours/commit/4e23d458fb66bb0beb6880cffbaf9b1874474e79. Note that this fork was done from the v0.1.3 commit, as this is the version currently published to PyPI and the one I have been using in my project.

jordanmkoncz avatar Dec 13 '17 05:12 jordanmkoncz

Any updates on this @arteria or @walterrenner?

jordanmkoncz avatar Jan 15 '18 03:01 jordanmkoncz