#15633 closed Bug (fixed)
Bad documentation of post_syncdb signal
Reported by: | Vlastimil Zíma | Owned by: | Justin Lilly |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Signal post_sycndb is badly documented:
- documentation says that created_models is list, but emit_post_sync_signal is called with set when it is called from syncdb command. Surprisingly it is called with set from flush command, so there is probably error in code as well.
- documentation suggests that post_syncdb signal is called only when table is created, so it looks like you can use it to change database structure (create contraints, triggers, ...) These SQL fail when yout post_sycndb handler is called from flush, because flush does not change database structure (except SQLs with 'IF NOT EXISTS'-like conditions). Documentation should noted that handlers of this signal should not change database structure and for such cases customize sql hack in syncdb should be used.
Change History (13)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Type: | → Bug |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|
comment:4 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
follow-up: 6 comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
UI/UX: | unset |
Seems to be a duplicate of #5848 -- but this ticket was opened on Mach 17 2011 against trunk and the other ticket was fixed on Sep 12 2010.
comment:6 by , 13 years ago
follow-up: 8 comment:7 by , 13 years ago
Regarding your second point, there's already a solution for this problem, see https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data
comment:8 by , 13 years ago
Replying to aaugustin:
Regarding your second point, there's already a solution for this problem, see https://docs.djangoproject.com/en/dev/howto/initial-data/#providing-initial-sql-data
This does not work one would expected from documentation.
If I create initial SQL like
ALTER TABLE "some_table" ADD CONSTRAINT "some_table_constraint1" CHECK (some_column = 45);
This will make flush
command fail, as it emits post_syncdb
signal marking that table is created (but it is not). This can be sometimes prevented using IF NOT EXISTS
condition, but not always.
comment:9 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 13 years ago
Has patch: | set |
---|
comment:11 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
applied - built docs, reads well
Bug in description: flush command calls emit_post_sync_signal with list of models as in documentation