django ignores on_delete=Cascade when creating Postgresql-DBs -


i use django 1.7 create postgresql 9.3 db several tables contain foreign-key constraints. db used warehouse in objects have physical location. if object (in table stored_objects) deleted, i'd delete it's position, model location looks like:

class object_positions(models.model):    obj_id = models.foreignkey(stored_objects, db_column='obj_id',on_delete=models.cascade)   (...) 

the constraint in db (after syncdb) looks this:

alter table object_positions   add constraint stored_obj_fkey foreign key (obj_id)       references "stored_objects" (id) match simple       on update no action on delete no action; 

is there else have constraint right in db?

django uses it's own code handle cascades, they're not implemented on database level. main reason maintain consistent behaviour across backends, , allow model signals fire cascaded deletions. if reason want constraint on database level, you'll have edit table yourself. wouldn't recommend unless have compelling reason (such app accessing database, bypassing django).


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -