Agree with Tom that ccbv is a great resource for help with CBVs.  In fact, 
I used it to help me with this comment.

I would probably override the delete() method in DeleteView to do what you 
want to do.  The original justs deletes the record and redirects to the 
supplied URL:


   1. def delete(self, request, *args, **kwargs): 
   2. """ 
   3. Calls the delete() method on the fetched object and then 
   4. redirects to the success URL. 
   5. """ 
   6. self.object = self.get_object() 
   7. self.object.delete() 
   8. return HttpResponseRedirect(self.get_success_url())
   
   One could easily replace line 7 with your custom code:
   
       now = datetime.datetime.utcnow().replace(tzinfo=utc)
       self,object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
       self.object.save()
   
   Which would update the date as needed.
   
   Also, I would include the date check in the get_object() method:
   
   def get_object(self,queryset=None)
       obj = super(MyDeleteView,self).get_object(queryset)
       if obj.date_deleted is not None:
           raise Http404
       return obj
   
   Not tested, but will probably work :)
   

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to