1👍
You restrict the queryset in the GET branch, but not the POST branch. That means that the POST branch creates a formset containing every transaction.
0👍
replace your for loop:
for trans in updated_transactions.exclude(paid_amount=None, date_cleared=None).all():
trans_to_change = Transaction.objects.get(pk=trans.pk)
trans_to_change.paid_amount = trans.paid_amount
trans_to_change.date_cleared = trans.date_cleared
trans_to_change.paid_currency = trans_to_change.entered_currency
trans_to_change.paid_amount_usd = Decimal(str(trans_to_change.paid_amount * Decimal(str(trans_to_change.exchange_rate)).quantize(Decimal('0.01')))).quantize(Decimal('0.01'))
trans_to_change.edited_by = request.user
trans_to_change.cleared = True
trans_to_change.save()
- [Answer]-Validate nested form in Django
- [Answer]-How do you save a relationship with an existing tag otherwise create the tag, in django views?
- [Answer]-A simple database inner join using django
- [Answer]-How can I create a django url specific to a user?
- [Answer]-Unable to access static files with NGINX, gunicorn and Django
Source:stackexchange.com