I got this long instruction for request in view
contributions = user_profile.contributions_chosen.all()\
.filter(payed=False).filter(belongs_to=concert)\
.filter(contribution_def__left__gt=0)\
.filter(contribution_def__type_of='ticket')
What I use in my template
context['contributions'] = contributions
And later in this view, I make changes (adding or removing an entry) to the contrib_chosen table, and if I want to update my context ["installments"], I need to query the database with the same length query.
contributions = user_profile.contributions_chosen.all()\
.filter(payed=False).filter(belongs_to=concert)\
.filter(contribution_def__left__gt=0)\
.filter(contribution_def__type_of='ticket')
And refresh my context again
context['contributions'] = contributions
So, I wondered if I could in any case avoid repeating myself, overestimate the contribution so that it really reflects the real data in the database. Ideally, I would change the tabs of the request, and its values would be updated, and at the same time, the database would reflect these changes, but I do not know how to do this.
UPDATE: This is what I do between two context ['contributions'] = contributions
_chosen ( m2m),
contribution = Contribution.objects.create(kwarg=something,kwarg2=somethingelse)
user_profile.contributions_chosen.add(contribution)
contribution.save()
user_profile.save()
contrib = user_profile.contributions_chosen.get(id = 1) user_profile.contributions_chosen.get(ID = request.POST [ ' contribution.delete()
, contrib_chosen, .
?
UPDATE
, , eval ,
() [ "" ], .
, , .