-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limits the number of related items added to the choices dictionary on RelatedField #3330
Conversation
As presented I think this would actually break the An alternative might be a |
It seems to be working fine on my side with a dropdown using html_cutoff, but I haven't tested other cases yet. I'm not sure what you mean with the last paragraph. Why would you want to call that get_choices() with different cutoffs? |
What I mean is I'm not totally comfortable with '.choices' always being hard-limited. (Tho its possible I could be convinced to change my mind on that) |
…ons to limit the amount of choices
I guess that by doing this we keep the current RelatedField.choices behaviour while allowing iter_options to limit how many choices we have. I know this is lacking tests and we should probably have some for it. I might look into it later. |
Looks about right, yeah. |
I also have problems with RelatedField to table with many records. OPTIONS response can be delay to 1 minute which is not good. I also thought about proper solution for this problem and I don't think that limiting
Probably we need an argument for that field that will mark the field as "raw_id" like in the django admin. And for this field there will be no select in the HTML view and there will be no What you think about that? |
I think what we present in |
I would like to add that I am encountering this issue in my own server (with about 220k related records for a field) which utterly crushes the app. I tested the patch above and it's working for me. You also have my vote for removing the enumeration of related choices in |
Probably a good plan. |
+1 choices enumeration in an OPTIONS request is making the response HUGE, and the browsable API unusable for me in 3.3.2 |
Thanks! 👍 |
Most welcome. Pleasure to get the triage back on track now that we're (mostly) funded! 😎 |
Refs #3329
Solves a memory issue when evaluating very large querysets