Tuesday, October 3, 2017

Re: There is any way to prevent cascade delete on FK field, without using signal?

explicitly define what to do when there is a deletion.

use the "on_delete" parameter of ForeignKey/OneToOneField

on django <=1.11, on_delete is optional, and its default value is CASCADE.

after django >- 2.0, it is mandatory to set "on_delete"


https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.on_delete



2017-10-03 13:28 GMT-03:00 Fellipe Henrique <fellipeh@gmail.com>:
There is any way to prevent cascade delete on FK field, without using signal?

I need to block the Delete process, not to set NULL on field.. 

Regards!


T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

--
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-users@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/CAF1jwZH4s%3DSnCaS3hqCiZPQd%3D4vvZPYU1EH7oEp1ixpNrg5ERw%40mail.gmail.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...

--
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-users@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/CAPVjvMbA6Y%3DP8jKQr_MNRNBSXNXo8hoyxtrC%3DdXF3hMziDPhDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment