query = Movimentacao.objects.all()
for m in movimentacoes:
# this query couldn't be update everytime an item is added to database
q = query.filter(entrada_saida=m[0], data=m[1], movimentacao=m[2], produto=m[3], instituicao=m[4], quantidade=m[5], preco_unitario=m[6], valor_da_operacao=m[7])
# check if the object exist
if q.exists():
pass
else:
# new object is going to be created because it does NOT exist yet
line = Movimentacao(entrada_saida=m[0], data=m[1], movimentacao=m[2], produto=m[3], instituicao=m[4], quantidade=m[5], preco_unitario=m[6], valor_da_operacao=m[7])
counter += 1
line.save()
How can I prevent this 'q' query from being update everytime the looping is repeated? What I'd like is get the original objects from the database.