Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Removed usage of field.choices that triggered full table load#8950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
auvipy merged 1 commit intoencode:masterfromlnagel:patch-1
Jun 13, 2023

Conversation

@lnagel
Copy link
Contributor

@lnagellnagel commentedApr 17, 2023
edited
Loading

Description

Removed the{{ field.choices|yesno:",disabled" }} block because this triggers the loading of full database table worth of objects just to determine whether the multi-select widget should be set as disabled or not.

Since this "disabled" marking feature is not present in the normal select field, then I propose to remove it also from the multi-select.

The reason why I found this was that HTML forms in the browsable API became extremely slow, but only when relation fields with many=True were being used.

Removed the `{{ field.choices|yesno:",disabled" }}` block because this triggers the loading of full database table worth of objects just to determine whether the multi-select widget should be set as disabled or not.Since this "disabled" marking feature is not present in the normal select field, then I propose to remove it also from the multi-select.
{% endif %}

<divclass="col-sm-10">
<selectmultiple{{field.choices|yesno:",disabled" }}class="form-control"name="{{ field.name }}">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

how can we determine this won't create any regression?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

From my side I will include the modified template in our current projects. So far this seems to have resolved the issue of forms not loading within 30 seconds that the application server is willing to wait on DRF request processing and the end user getting a gateway timeout.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Another way to reason about this: as long as field.choices are present (field queryset is non-empty), then the select element is not assigned the "disabled" html attribute. Theoretically speaking it should not matter whether a multi-select field without any choices is disabled or enabled - there isn't anything to select.

Is anyone aware of some corner case situation that we should be aware of?

auvipy reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

is it possible to add test coverage for this?

@auvipyauvipy closed thisApr 19, 2023
@auvipyauvipy reopened thisApr 19, 2023
@auvipyauvipy requested a review fromjuspenceApril 20, 2023 04:08
@auvipyauvipy added this to the3.15 milestoneJun 13, 2023
@auvipyauvipy merged commit8333134 intoencode:masterJun 13, 2023
auvipy added a commit that referenced this pull requestJun 17, 2023
* fix OpenAPIRenderer for timedelta* added test for rendering openapi with timedelta* fix OpenAPIRenderer for timedelta* added test for rendering openapi with timedelta* Removed usage of field.choices that triggered full table load (#8950)Removed the `{{ field.choices|yesno:",disabled" }}` block because this triggers the loading of full database table worth of objects just to determine whether the multi-select widget should be set as disabled or not.Since this "disabled" marking feature is not present in the normal select field, then I propose to remove it also from the multi-select.* Added Deprecation Warnings for CoreAPI (#7519)* Added Deprecation Warnings for CoreAPI* Bumped removal to DRF315* Update rest_framework/__init__.py* Update rest_framework/filters.py* Update rest_framework/filters.py* Update tests/schemas/test_coreapi.py* Update rest_framework/filters.py* Update rest_framework/filters.py* Update tests/schemas/test_coreapi.py* Update tests/schemas/test_coreapi.py* Update setup.cfg* Update rest_framework/pagination.py---------Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>* Update copy right timeline* Fix NamespaceVersioning ignoring DEFAULT_VERSION on non-None namespaces (#7278)* Fix the case where if the namespace is not None and there's no match,  NamespaceVersioning always raises NotFound even if DEFAULT_VERSION  is set or None is in ALLOWED_VERSIONS* Add test cases* fix OpenAPIRenderer for timedelta* added test for rendering openapi with timedelta* added testcase for rendering yaml with minvalidator for duration field (timedelta)---------Co-authored-by: Rizwan Shaikh <rshaikh@ces-ltd.com>Co-authored-by: Lenno Nagel <lenno@namespace.ee>Co-authored-by: David Smith <39445562+smithdc1@users.noreply.github.com>Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>Co-authored-by: Konstantin Kuchkov <konstantin.kuchkov@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@auvipyauvipyauvipy approved these changes

@juspencejuspenceAwaiting requested review from juspence

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.15

Development

Successfully merging this pull request may close these issues.

2 participants

@lnagel@auvipy

[8]ページ先頭

©2009-2025 Movatter.jp