Ticket #511 (closed defect: fixed)
syncdb does not import 'management' module from external apps
| Reported by: | jaap@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.7.2 |
| Component: | commands | Version: | 0.7.1 |
| Keywords: | syncdb management signals | Cc: |
Description
What steps will reproduce the problem?:
- Add defaultsite (http://pypi.python.org/pypi/django-defaultsite/1.1) to INSTALLED_APPS
- Run syncdb
- Check the created site object
What is the expected output? What do you see instead?:
I expected a site object based on my settings for defaultsite. Instead I see the standard example.com site.
What may cause this:
South overwrites Django's built in syncdb command. Even though in the background the old command still gets called, the following does not always work:
http://code.djangoproject.com/wiki/Signals#Howsignalswork
whenever manage.py syncdb is run, it loops through every application in the
INSTALLED_APPS setting, and looks to see if any apps contain a module called
management; if they do, manage.py imports them before installing any models,
which means that any dispatcher connections listed in an app's management module
will be set up before model installation happens.
I suspect the reason for this is that South builds its own list of apps to sync (apps_needing_sync) based on django.db.models.get_apps().
In my case defaultsite, doesn't provide any models by itself. Therefore it doesn't get included in the lists of apps sent to the 'real' syncdb command.

Implemented in [6ce9576a7edd].