Hey James,
Just to add to what was already said there's a ticket tracking the addition
of
database level foreign constraints.[0]
Cheers,
Simon
[0] https://code.djangoproject.com/ticket/21961
Le samedi 23 juin 2018 09:56:23 UTC-4, Tomasz Knapik a écrit :
>
> If you search about it on the Intern
Indeed! I have actually used the admin site to do it before I posted this
it's just something I didn't know was by design. After numerous searches I
came here but I may have been asking the wrong questions in google :).
The shell would be good if I have quite a few I need to delete. Thankfully
If you search about it on the Internet many sources claim that Django
does not set those constraints on the database level.
If you look at the code of the base code for database backends, you'll
notice that they don't mention on_delete at all. - https://github.com/d
jango/django/blob/6dd4edb1b4f54
well, nothing stopping you from doing the same in the django shell and
doing `Group.objects.get(pk = some_pk).delete`. that would be an
alternative for going straight to the db.
I can see some issues with this coming up, especially if you're doing
deletes with django's raw sql capability. But
OK. So it's by design.
So during development I can't go straight to the database and delete a
"Group" quickly due to an error I made. I'd have to set up tests to deal
with it at an application level.
No probs though. I'm just happy I know it can't be done and not that it's a
bug I'd have to wa
On zaterdag 23 juni 2018 14:40:30 CEST Jason wrote:
> Not quite. If you run python manage.py sqlmigrate
> , you can see the SQL generated for that migration.
>
> https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigr
> ate
>
> Because Django emulates Cascade, its done outs
Not quite. If you run python manage.py sqlmigrate
, you can see the SQL generated for that migration.
https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigrate
Because Django emulates Cascade, its done outside of the db, and therefore
shouldn't be a db-level constraint.
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:
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)
>
I'm having a little trouble with my "through" table. I've set the modal to
have two Foreign Key fields. Ex. below:
class Person(models.Model):
title = models.CharField(max_length=255)
class Group(models.Model):
title = models.CharField(max_length=255)
members= models.ManyToManyField
10 matches
Mail list logo