Opened 13 years ago

Closed 13 years ago

#15113 closed (invalid)

post_sync signal's created_models are incorrect with flush

Reported by: David Cramer Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The flush command calls emit_post_sync_signal with all models, which is incorrect. This can send models as being "created" which actually don't even exist on a database.

For example, given that we have a database called foo, which does not contain django.contrib.sites, and we run the flush command, it will pass all installed models to the create_default_site method, even though Site isnt available here. With this behavior, Site then tries to create a row on this database which throws a table does not exist error.

This can be fixed by changing the flush command to match the syncdb command so that it only passes created_models which are present on this database:

e.g. (taken from syncdb)

        all_models = [
            (app.__name__.split('.')[-2],
                [m for m in models.get_models(app, include_auto_created=True)
                if router.allow_syncdb(db, m)])
            for app in models.get_apps()
        ]

Attachments (1)

flush.diff (1.6 KB ) - added by David Cramer 13 years ago.
Diff against DISQUS codebase

Download all attachments as: .zip

Change History (2)

by David Cramer, 13 years ago

Attachment: flush.diff added

Diff against DISQUS codebase

comment:1 by David Cramer, 13 years ago

Resolution: invalid
Status: newclosed

Already fixed in trunk :)

Note: See TracTickets for help on using tickets.
Back to Top