#15113: post_sync signal's created_models are incorrect with flush
---------------------------+------------------------------------------------
Reporter: dcramer | Owner: nobody
Status: new | Milestone:
Component: Uncategorized | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
---------------------------+------------------------------------------------
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()
]
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/15113>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.