Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecify a template name in class based View
    primarykey
    data
    text
    <p>I am new to Django and trying to work from <a href="https://github.com/sigurdga/django-jquery-file-upload" rel="nofollow">django-jquery-file-upload</a></p> <p>It has introduced me to class based Views.</p> <p>I'm trying to replicate one of these class based views to contain a share link that will refer back to individual links in the gallery.</p> <p>the class i'm trying to adapt is:</p> <pre><code>class PictureDeleteView(DeleteView): model = Picture def delete(self, request, *args, **kwargs): """ This does not actually delete the file, only the database record. But that is easy to implement. """ self.object = self.get_object() self.object.delete() if request.is_ajax(): response = JSONResponse(True, {}, response_mimetype(self.request)) response['Content-Disposition'] = 'inline; filename=files.json' return response else: return HttpResponseRedirect('/upload/new') class JSONResponse(HttpResponse): """JSON response class.""" def __init__(self,obj='',json_opts={},mimetype="application/json",*args,**kwargs): content = simplejson.dumps(obj,**json_opts) super(JSONResponse,self).__init__(content,mimetype,*args,**kwargs) </code></pre> <p>This defaults to the template name picture_confirm_delete.html</p> <p>How can i rewrite a class with the same functionality except that it points to a different template? or better still &amp; in keeping with 'DRY' how can i reuse this class on another template?</p> <p>I've had a look over the documentation <a href="https://docs.djangoproject.com/en/dev/topics/class-based-views/intro/" rel="nofollow">here</a> but can't seem to adapt it to my needs.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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