niwinz / django-jinja

Simple and nonobstructive jinja2 integration with Django.
http://niwinz.github.io/django-jinja/latest/
BSD 3-Clause "New" or "Revised" License
363 stars 102 forks source link

Model 'cms.page_placeholders' was already registered. #189

Closed POD666 closed 2 years ago

POD666 commented 7 years ago

import_module: menus.templatetags.menu_tags (menu_tags.pyc) #print to debug import_module: menus.templatetags.menu_tags (menu_tags.py) #print to debug Model 'cms.page_placeholders' was already registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models. Model 'cms.page' was already registered. Reloading models is not advised as it can lead to inconsistencies, most notably with related models.

issue in django_jinja/backend.py: lambda x: x.endswith(".py") or x.endswith(".pyc")

probably it should search only for ".py" or skip loaded modules(ignore ext)

any advices?

niwinz commented 7 years ago

I'm not clearly understand the problem and how it is related to django-jinja

POD666 commented 7 years ago

django-jinja is searching and preloading available template filters or functions for jinja2 twice.

Check django_jinja/backend.py "_initialize_thirdparty". At first its loading from ".pyc", then from ".py". https://github.com/niwinz/django-jinja/blob/master/django_jinja/backend.py#L218

It's casue warnings.

niwinz commented 7 years ago

Yeah, seems like a minor bug.

In other hand, the template tags loading should be idempotent. So there are should not to be any problem in loading twice the template tags module. It has been working for a while at this manner, and I never found my self with that error.

wizpig64 commented 2 years ago

closing this as it's 5 years old.