modestboy8
modestboy8

Reputation: 11

django on_delete

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

Answers (1)

Milano
Milano

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

Related Questions