mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Copy 'help_text' through from the model field if it is not defined for the serializer field
This commit is contained in:
parent
35bd6ce927
commit
1bde26a7be
@ -118,7 +118,9 @@ class InvenTreeMetadata(SimpleMetadata):
|
|||||||
# Iterate through simple fields
|
# Iterate through simple fields
|
||||||
for name, field in model_fields.fields.items():
|
for name, field in model_fields.fields.items():
|
||||||
|
|
||||||
if field.has_default() and name in serializer_info.keys():
|
if name in serializer_info.keys():
|
||||||
|
|
||||||
|
if field.has_default():
|
||||||
|
|
||||||
default = field.default
|
default = field.default
|
||||||
|
|
||||||
@ -133,6 +135,15 @@ class InvenTreeMetadata(SimpleMetadata):
|
|||||||
elif name in model_default_values:
|
elif name in model_default_values:
|
||||||
serializer_info[name]['default'] = model_default_values[name]
|
serializer_info[name]['default'] = model_default_values[name]
|
||||||
|
|
||||||
|
# Attributes to copy from the model to the field (if they don't exist)
|
||||||
|
attributes = ['help_text']
|
||||||
|
|
||||||
|
for attr in attributes:
|
||||||
|
if attr not in serializer_info[name]:
|
||||||
|
|
||||||
|
if hasattr(field, attr):
|
||||||
|
serializer_info[name][attr] = getattr(field, attr)
|
||||||
|
|
||||||
# Iterate through relations
|
# Iterate through relations
|
||||||
for name, relation in model_fields.relations.items():
|
for name, relation in model_fields.relations.items():
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user