Expand my Community achievements bar.

SOLVED

On delete: models.CASCADE?

Avatar

Level 6

How to tell Campaign that if a record is deleted in table A, the same record, based on a field that would act as a Foreign Key, should also be deleted?

Is there any configuration I can do in the schema, so I get the on_delete=models.CASCADE other DB have?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @god_prophet ,

In the schema defination, in element tag of the link add integrity="own" (deleting the source occurrence leads to the deletion of the target occurrence)

To know about other possible integrity values, refer this document 

 

integrity (optional): referential integrity of the occurrence of the source table to the occurrence of the target table. Possible values are as follows:

  • define: it is possible to delete the source occurrence if it is no longer referenced by a target occurrence,
  • normal: deleting the source occurrence initializes the keys of the link to the target occurrence (default mode), this type of integrity initializes all foreign keys,
  • own: deleting the source occurrence leads to the deletion of the target occurrence,
  • owncopy: the same as own (in case of deletion) or duplicates the occurrences (in case of duplication),
  • neutral: does nothing.

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @god_prophet ,

In the schema defination, in element tag of the link add integrity="own" (deleting the source occurrence leads to the deletion of the target occurrence)

To know about other possible integrity values, refer this document 

 

integrity (optional): referential integrity of the occurrence of the source table to the occurrence of the target table. Possible values are as follows:

  • define: it is possible to delete the source occurrence if it is no longer referenced by a target occurrence,
  • normal: deleting the source occurrence initializes the keys of the link to the target occurrence (default mode), this type of integrity initializes all foreign keys,
  • own: deleting the source occurrence leads to the deletion of the target occurrence,
  • owncopy: the same as own (in case of deletion) or duplicates the occurrences (in case of duplication),
  • neutral: does nothing.