MultipleModelField should accept other types as iterable not just list
See original GitHub issueIt seems to me that MultipleModelField should accept any iterable such as a Django queryset
, tuple
, and set
– not just a list
.
I commonly have forms using forms.ModelMultipleChoiceField
which in the cleaned_data returns a queryset. I am having to wrap list
around the data from a forms.ModelMultipleChoiceField
to coerce it into a list for the library.
Views.py:
DuplicateMergeService.execute({
'duplicates':list(form.cleaned_data['duplicates']),
'by': request.user
})
Seems like MultipleModelField
should accept any iterable and not be restricted to list
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Field Data Types - Iterable Support Center
This article explains different values and data types for fields and events in ... If the field is not already cast, CSV imports...
Read more >Making Python Integers Iterable - Arpit Bhayani
In Python, Integers are not iterables but we can make them iterable by ... the range type which helps us iterate through all...
Read more >Iterables - Python Like You Mean It
An iterable is any Python object capable of returning its members one at a time, permitting it to be iterated over in a...
Read more >Iterable collections - Dart programming language
Iterables are a kind of collection. A collection can be empty, or it can contain many elements. Depending on the purpose, collections can...
Read more >Why is Java's Iterator not an Iterable? - Stack Overflow
An iterator is stateful. The idea is that if you call Iterable.iterator() twice you'll get independent iterators - for most iterables, anyway.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Personally switching from using the MultipleModelField -> forms.ModelMultipleChoiceField for queryset.
OR
@jackton1 Thanks for the feedback and mentioning the allow_unsaved. I guess @c17r already committed a change so I won’t submit the PR I started last night. Glad to see this improvement.