Skip to content
Snippets Groups Projects
Commit ff4ea67b authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'fix-create-element-browser' into 'master'

Avoid thousands of SQL queries when opening CreateElement in a browser

Closes #634

See merge request !1194
parents 8d22bd8a 91d675ce
No related branches found
No related tags found
1 merge request!1194Avoid thousands of SQL queries when opening CreateElement in a browser
......@@ -364,19 +364,33 @@ class ElementCreateSerializer(ElementLightSerializer):
Serialize an Element with a possible parent and image
"""
type = serializers.SlugField(source='type.slug')
corpus = serializers.PrimaryKeyRelatedField(queryset=Corpus.objects.none())
corpus = serializers.PrimaryKeyRelatedField(
queryset=Corpus.objects.none(),
style={'base_template': 'input.html'},
)
image = serializers.PrimaryKeyRelatedField(
queryset=Image.objects.using('default').all().select_related('server'),
required=False,
help_text='Link this element to an image by UUID via a polygon.',
style={'base_template': 'input.html'},
)
parent = serializers.PrimaryKeyRelatedField(
queryset=Element.objects.none(),
required=False,
allow_null=True,
style={'base_template': 'input.html'},
)
parent = serializers.PrimaryKeyRelatedField(queryset=Element.objects.none(), required=False, allow_null=True)
polygon = LinearRingField(
required=False,
help_text='Set the polygon linking this element to the image. '
'`image` must be set when this field is set. Defaults to a rectangle taking up the whole image.',
)
worker_version = serializers.PrimaryKeyRelatedField(queryset=WorkerVersion.objects.all(), required=False, allow_null=True)
worker_version = serializers.PrimaryKeyRelatedField(
queryset=WorkerVersion.objects.all(),
required=False,
allow_null=True,
style={'base_template': 'input.html'},
)
class Meta(ElementLightSerializer.Meta):
model = Element
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment