Eu tenho o seguinte:
answers = Answer.objects.filter(id__in=[answer.id for answer in answer_set.answers.all()])
então mais tarde:
for i in range(len(answers)):
# iterate through all existing QuestionAnswer objects
for existing_question_answer in existing_question_answers:
# if an answer is already associated, remove it from the
# list of answers to save
if answers[i].id == existing_question_answer.answer.id:
answers.remove(answers[i]) # doesn't work
existing_question_answers.remove(existing_question_answer)
Recebo um erro:
'QuerySet' object has no attribute 'remove'
Tentei todos os tipos para converter o QuerySet em um conjunto ou lista padrão. Nada funciona.
Como posso remover um item do QuerySet para que ele não o exclua do banco de dados e não retorne um novo QuerySet (já que está em um loop que não funciona)?