Reputation: 11
I have two models in django Photos and Posts (foreign key between them).
post = Posts.objects.get(pk=1)
post.delete() # all photos is deleted
. cascade delete. it's fine
but when I want delete from pgadmin error found... DETAIL: Key (id)=(1)
is still referenced from table "photos". why I can not delete from pgadmin ?
Upvotes: 0
Views: 398
Reputation: 18725
As far as I know, CASCADE deleting and such things does Django by itself, not your database. PGAdmin works with the raw database.
But deleting from the shell should work:
python manage.py shell
Posts.objects.get(pk=1).delete()
Upvotes: 1