Reputation: 35
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
Upvotes: 2
Views: 285
Reputation: 35
It turns out the problem was caused by django-debug-toolbar, more specifically the profiling panel whose hooks cause all views to be called twice.
Removing the debug_toolbar.panels.profiling.ProfilingDebugPanel
panel fixes the problem.
https://github.com/django-debug-toolbar/django-debug-toolbar/issues/267
The problem is known by the devs and is supposed to be fixed in the repos.
Upvotes: 1