summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-02-14 05:04:32 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:38:56 +0200
commite9259ae4c1ac0ff49a7ff97e068719903d52e438 (patch)
tree20497d2f1da523e97f1d0d0d9da8c5ee7226f08c /ishtar_common/forms.py
parent2e7eb5be6ee91f2cdc799ad87954a8d91685f583 (diff)
downloadIshtar-e9259ae4c1ac0ff49a7ff97e068719903d52e438.tar.bz2
Ishtar-e9259ae4c1ac0ff49a7ff97e068719903d52e438.zip
Query optimization for JSON dynamic fields
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 57f48ff95..7f9c8a400 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -269,18 +269,20 @@ class CustomForm(BSForm):
:return: ((order1, key1, field1), ...)
"""
fields = []
- for field in custom_form.json_fields.values(
- "order", "label", "json_field__name", "json_field__value_type",
- "help_text", "json_field__key").order_by('order').all():
- key = "data__" + field["json_field__key"]
+ q = custom_form.json_fields.values(
+ 'label', 'help_text', 'order', 'json_field__key',
+ 'json_field__value_type', 'json_field__name',
+ ).order_by('order')
+ for field in q.all():
+ key = "data__" + field['json_field__key']
field_cls, widget = forms.CharField, None
- if field["json_field__value_type"] in JSON_VALUE_TYPES_FIELDS:
+ if field['json_field__value_type'] in JSON_VALUE_TYPES_FIELDS:
field_cls, widget = JSON_VALUE_TYPES_FIELDS[
- field["json_field__value_type"]]
- attrs = {'label': field["label"] or field["json_field__name"],
+ field['json_field__value_type']]
+ attrs = {'label': field['label'] or field['json_field__name'],
'required': False}
- if field["help_text"]:
- attrs['help_text'] = field["help_text"]
+ if field['help_text']:
+ attrs['help_text'] = field['help_text']
if widget:
attrs['widget'] = widget()
if field_cls == widgets.Select2DynamicField: