-
Notifications
You must be signed in to change notification settings - Fork 105
add_to_builtins in settings.py fails #116
Comments
Confirmed, you are right. I have to say I didn't know of the existence of
django-uni-form is going to be replaced by django-crispy-forms https://github.com/maraujop/django-crispy-forms Although it hasn't been publicly announced yet. I'm not updating fixes to django-uni-form anymore. Could you please have a look at it, maybe upgrade to it (instructions), latest version is 1.0.0 (tests are passing) and submit the pull request there. I won't have time to fix this myself for a couple days. Thanks, cheers |
@marujop, there is a reason why people don't use add_to_builtins more. It is a maintenance nightmare in the making. It is one of the warning signs when you review projects, if they have it, then odds are they are being 'clever' in other places. "Explicit is better then implicit" is the way to go. |
Wow, I see. I found this quote by Carl Meyer:
It looked like a good idea, to have the tags loaded everywhere in the project. Not meaning django-crispy-forms but the project that uses it. That avoid having to repeat loads everywhere, right? |
It's also a performance thing. 'Repeat' loads are a good thing, since all you are doing is adding them into templates manually. Which means those pages that don't use a particular template library aren't being throttled by Django's notoriously slow templatetag library finder (which checks every INSTALLED_APP plus the Django defaults). Defining them in Ouch. |
You are right, this looks as a performance eater... I'm convinced not to use it :D I don't want to end up coding node.js no, no, no. |
Hi,
When using the django-uni-form templatetags through add_to_builtins in settings.py (the most logical location for using add_to_builtins) the server fails to start.
This is a new bug since after 0.7.0.
It is caused by the use of get_template in the templatetags modules. Since get_template is called at module load-time and get_template requires settings.py to have been fully loaded your code cannot be imported from settings.py.
An example of a call to get_template at module root (i.e. not inside some function) is:
https://github.com/pydanny/django-uni-form/blob/master/uni_form/templatetags/uni_form_tags.py#L142
But there are more, grepping will quickly reveal them.
A simple solution would be to make the associated variables lazily initialized, i.e. set them as None at module-load time and always access them via some getter that checks their value. If necessary I could provide this code for you.
The text was updated successfully, but these errors were encountered: