Home:ALL Converter>mongoengine calls causes django view to be called twice

mongoengine calls causes django view to be called twice

Ask Time:2012-09-21T21:12:46         Author:schwert

Json Formatter

when I create a new object it gets inserted into mongodb twice,
when I try to delete one, it does so and then try again only to tell me it couldn't find the object
it probably does the same thing on queries too tough it's not really a problem right now

I'm using django 1.4.1 with mongoengine 0.7.5

the code of my delete view is

def delbadge(request, oid):
    log.info('searching')
    try:
        badg = BgBadge.objects(id=oid)[0]
    except:
        log.error('not found')
        raise Http404
    badg.delete()
    log.info('deleted')
    return HttpResponseRedirect('/badge/')
    #raise Http404

what it gives me is

searching
deleted
searching
not found

if I remove the badg.delete() I get

searching
deleted

same thing when I replace the return HttpResponseRedirect('/badge/') by raise Http404

So I tested the mongoengine code out of django and the django code without mongoengine and they both work just fine

edit:
the handler for /badge/ is url(r'^badge/$', AllBadges.as_view()),
I checked the http requests and it doesn't appear to be the cause

update:
I tried on another computer and get the same behavior

Author:schwert,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12531302/mongoengine-calls-causes-django-view-to-be-called-twice
yy