How to "Undo" in two different Django views

Skip to first unread message

Aug 8, 2016, 6:34:12 AM8/8/16
to django-reversion discussion group
Hello all,

I would like to "undo" the latest action from my Django application and I've read the document but I still have no idea how to do. Can anyone give me an example? Many thanks.

Here is my current code:

def opponent_shooting(request, team_id, game_id):

    isMade_opponent = request.COOKIES["OppoMade"]

    hotzone_id_opponent = request.COOKIES["OppoHotZone"]

    game = Game.objects.get(pk=game_id)

    team = Team.objects.get(pk=team_id)

    with reversion.create_revision():

        oppo_obj = OpponentHotZone(game=game, opponent=game.opponent,team=team, zone=hotzone_id_opponent)

        if isMade_opponent == "Y":

            oppo_obj.isMade = True


            oppo_obj.isMade = False

        # Store some meta-information.


    return redirect('playball', team_id=team_id, game_id=game_id)

def undo_opponent_shooting(request, team_id, game_id):

    revision = Revision.objects.filter("-date_created")[0]

    versions = Version.objects.get_for_object(revision)


    return redirect('playball', team_id=team_id, game_id=game_id)

Dave Hall

Aug 9, 2016, 5:27:10 AM8/9/16
to django-reversion discussion group
I don't thing that django-reversion is suitable for this use-case. To revert the last action, you simply need to delete the last OpponentHotZone model you created. It'll probably be much simpler to do that directly.

You received this message because you are subscribed to the Google Groups "django-reversion discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit
Reply all
Reply to author
0 new messages