Note that there are some explanatory texts on larger screens.

plurals
  1. POBaseDeleteView throws AttributeError (render_to_response missing)
    text
    copied!<p>I try to implement a view based on BaseDeleteView for a website that acts as a frontend to an REST backend. Both sides communicate over HTTP requests. What I want to achieve is that I send a <code>GET</code> request to an activation URI (send per email after registration). Inside this view I first send a HTTP request to a backend, and then delete the activation object from the database of the frontend. I don't want to have a confirmation page, so <code>DeleteView</code> is not possible.</p> <pre><code>class ActivationView(BaseDeleteView): success_url = "/activation/success/" def get_object(self, queryset=None): uuid = self.kwargs['uuid'] try: obj = AccountRegistration.objects.get(uuid=uuid) except ObjectDoesNotExist: raise Http404('Registration not found.') return obj def delete(self, request, *args, **kwargs): obj = self.get_obj() if obj.expire_date &lt; datetime.now(): obj.delete() raise Http404('Registration expired.') # send a http request to the backend t = Transaction('/activate/%s/' % obj.account_name) t.emit() # delete the object obj.delete() # and redirect the request return HttpResponseRedirect(self.get_success_url()) </code></pre> <p>My <code>urls.py</code> looks like that:</p> <pre><code>url(r'^activate/(?P&lt;uuid&gt;\w+)/$', ActivationView.as_view(), name="account-activate"), </code></pre> <p>But I get the following error:</p> <pre><code>Traceback (most recent call last): File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__ return self.application(environ, start_response) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__ response = self.get_response(request) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/views/generic/base.py", line 47, in view return self.dispatch(request, *args, **kwargs) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in dispatch return handler(request, *args, **kwargs) File "/home/crito/.pythonbrew/venvs/Python-2.7.2/thirty-web/lib/python2.7/site-packages/django/views/generic/detail.py", line 100, in get return self.render_to_response(context) AttributeError: 'ActivationView' object has no attribute 'render_to_response' </code></pre> <p>In my eyes it shouldn't even call render_to_response. Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload