A
A
Alexander Proshchenkov2018-09-17 12:13:59
Python
Alexander Proshchenkov, 2018-09-17 12:13:59

How to leave people with only certain id values ​​in form[people] when editing?

Gets a field from an already entered form:

state = get_object_or_404(State, pk=pk)
form = StateForm(request.POST, instance=state)
print(form['people'])

I get a list of all people (there are about 900 of them)
how to leave in form['people'] only people with certain id (known in advance) and saved selected:True
You can iterate over the values, but it will be very long-_-

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Proshchenkov, 2018-09-17
@Keltor

Solved the issue by brute force. Runs pretty fast

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question