M
M
maddread2016-02-11 13:12:16
PostgreSQL
maddread, 2016-02-11 13:12:16

How to properly create dependencies in postgres for django?

I noticed that when creating dependent django models, even if there is an on_delete=models.CASCADE option, ON DELETE NO ACTION is still set in the constraints of the created table.
At the same time, Django itself monitors the integrity of the database when deleting records in the slave table, deleting dependent records in the leader, of course, when manipulating data within Django itself.
If I work with the database directly, then I have to monitor the integrity myself, or change dependencies. If I change constraint to ON DELETE CASCADE - won't that interfere with Django?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maddread, 2016-03-03
@maddread

I tried it, it doesn't bother me. At the same time, it is still better to impose more stringent and desirable restrictions directly in postgres.

I
Ilya Erokhin, 2016-02-25
@AirWorker

> If I change constraint to ON DELETE CASCADE - won't that interfere with Django?
Most likely, in this case, the Django ORM will, as before, try to remove dependent lines itself, that is, first the dependencies, then what they wanted to remove. Better to test.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question