Mark as deleted instead of actually deleting in DeleteView

69 views
Skip to first unread message

Rakhee Menon

unread,
Sep 21, 2017, 5:39:41 AM9/21/17
to Django users
Hello Everyone ,
Can anyone tell me how to write views where, when clicked  on delete button the data shouldn't get deleted only the flag should turn 0

Fabio C. Barrionuevo da Luz

unread,
Sep 21, 2017, 5:45:43 AM9/21/17
to django...@googlegroups.com

2017-09-21 6:39 GMT-03:00 Rakhee Menon <menonr...@gmail.com>:
Hello Everyone ,
Can anyone tell me how to write views where, when clicked  on delete button the data shouldn't get deleted only the flag should turn 0

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/133d2433-2902-4856-a4e9-8800363db0ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul


Blog colaborativo sobre Python e tecnologias Relacionadas, mantido totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e mandar o pull-request. Leia mais sobre como publicar em README.md e contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python ou é útil para quem usa Python? Está esperando o que? Publica logo, que estou louco para ler...

James Schneider

unread,
Sep 21, 2017, 11:33:47 AM9/21/17
to django...@googlegroups.com
On Sep 21, 2017 2:39 AM, "Rakhee Menon" <menonr...@gmail.com> wrote:
Hello Everyone ,
Can anyone tell me how to write views where, when clicked  on delete button the data shouldn't get deleted only the flag should turn 0

Just use a standard update view that toggles the field that you are using for the object status. You can make the buttons on the form say whatever you'd like.

I would also recommend overriding the default model manager to automatically exclude objects that have been "deleted" if that makes sense for your project. Otherwise you'll need to remember to exclude those deleted objects manually everywhere.

-James
Reply all
Reply to author
Forward
0 new messages