OK, understood. However, If you set up CASCADE on the model surely when it 
creates the table on the database level it surely should set ON DELETE 
CASCADE not ON DELETE NO ACTION on the CONSTRAINT?

On Saturday, 23 June 2018 10:54:44 UTC+1, Melvyn Sopacua wrote:
>
> On zaterdag 23 juni 2018 00:56:36 CEST James Bellaby wrote:
>
>  
>
> > However when looking are the SQL in Postgresql it's created the 
> Membership
>
> > table constraint for the Group id with "ON DELETE NO ACTION"
>
> > 
>
> > CONSTRAINT groups_membership_group_id_d4404a8c_fk_groups_group_id FOREIGN
>
> > KEY (group_id)
>
> > REFERENCES public.groups_group (id) MATCH SIMPLE
>
> > ON UPDATE NO ACTION
>
> > ON DELETE NO ACTION
>
> > DEFERRABLE INITIALLY DEFERRED,
>
> > 
>
> > My understanding was that setting CASCADE on the group in the Membership
>
> > modal would set ON DELETE CASCADE for the Membership table CREATE?
>
> > 
>
> > If it's not a bug and I've missed something, I apologies in advance.
>
>  
>
> You missed the part where Django implements this at the application level 
> by emulating this 
> <https://docs.djangoproject.com/en/2.0/ref/models/fields/#django.db.models.CASCADE>.
>  
> This is (among other things) to be able to run signals 
> <https://github.com/django/django/blob/master/django/db/models/deletion.py#L276>,
>  
> which it can't do if the database is doing the deletion.
>
>  
>
> -- 
>
> Melvyn Sopacua
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb0457ef-fda9-4bca-8a46-1e66455ccf2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to