pydanny/django-uni-form — Issue #116: add_to_builtins in settings.py fails
Author: vanschelven
Created: 2011-11-02 16:27:49+00:00
State: open

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.