ckrybus / crispy-bulma

Bulma template pack for django-crispy-forms
MIT License
27 stars 7 forks source link

Exception while resolving variable 'form_error_title' in template 'bulma/uni_form.html' in debug log #16

Open leolivier opened 7 months ago

leolivier commented 7 months ago

Hi

crispy-bulma              0.11.0 
django-crispy-forms       2.1        

When using bulma crispy forms, it seems to be working fine as long as I don't set the logging in DEBUG level. If I change django logging to DEBUG, my log is totally overwhelmed (thousands of line for each screen) by errors starting with Exception while resolving variable 'form_error_title' in template 'bulma/uni_form.html' Part of the stack trace is:

System check identified no issues (0 silenced).
..Exception while resolving variable 'form_error_title' in template 'bulma/uni_form.html'.
Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 875, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'form_error_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 881, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(
                                            ^^^^^^^^
AttributeError: type object 'Context' has no attribute 'form_error_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 891, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'form_error_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 898, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [form_error_title] in [{'True': True, 'False': False, 'None': None}, {'field_class': '', 'field_template': 'bulma/field.html', 'form_show_errors': True, 'form_show_labels': True, 'label_class': '', 'form': <AuthenticationForm bound=True, valid=False, fields=(username;password)>}, {}]
Exception while resolving variable 'exclude_field_wrapper' in template 'bulma/uni_form.html'.
Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 875, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'exclude_field_wrapper'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 881, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(
                                            ^^^^^^^^
AttributeError: type object 'Context' has no attribute 'exclude_field_wrapper'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 891, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'exclude_field_wrapper'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/olivi/miniconda3/envs/cousinsmatter/lib/python3.12/site-packages/django/template/base.py", line 898, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [exclude_field_wrapper] in [{'True': True, 'False': False, 'None': None}, {'field_class': '', 'field_template': 'bulma/field.html', 'form_show_errors': True, 'form_show_labels': True, 'label_class': '', 'form': <AuthenticationForm bound=True, valid=False, fields=(username;password)>}, {'forloop': {'parentloop': {}, 'counter0': 0, 'counter': 1, 'revcounter': 2, 'revcounter0': 1, 'first': True, 'last': False}, 'field': <django.forms.boundfield.BoundField object at 0x7fa507190560>}, {}]

Then (due to the embedded exception I think), I have the same stack trace for the variables named exclude_field_wrapper , which in turns trigger the same stack for the variable wrapper_class, then form_horizontal (4 or 5 times the same stack trace)....

And then it restarts the same whole stack trace multiple times...

ckrybus commented 7 months ago

Hi, I can reproduce it, but it is not something which can be fixed easily. We would need to modify the global Field context, but Field is being imported from django-crispy-forms ...

The extra context from crispy-bootstrap5, for example use_custom_control, is declared in the package django-crispy-forms, but I can't do that here.

This "error" is more or less normal when using django and is not an issue in production. I'll leave it open for now, maybe someone else has an idea how to fix it. For me it is a low priority issue.