when you execute bin/django syncdb
a list with all apps that have been and those that haven't been synced gets returned.
Synced:
> south
> raven.contrib.django
> django.contrib.staticfiles
...
Not synced (use migrations):
- django_extensions
...
How can I intercept this information? I was looking at the post_syncdb
signal but the call_back does not contain the info I was hoping for.
Edit Maybe I wasn't clear enough. I know I could do something like:
output = Popen(["bin/django","syncdb"], stdout=subprocess.PIPE).communicate()[0]
or:
def get_syncdb_output():
content = StringIO()
call_command('syncdb', stdout=content)
import ipdb; ipdb.set_trace()
content.seek(0)
ansi_escape = re.compile(r'\x1b[^m]*m')
return ansi_escape.sub('', content.read().decode('utf8'))
But I want to know in which django class or method this information is being produced!
You know that Django is OSS, don't you ? The answer is written in plain text in the source code of
django/core/management/commands/syncdb.py
. For Django 1.6.5, its:For django 1.7.x and onward you'll have to look at
django/core/management/commands/migrate.py
. It's a bit more complex code but basically you'll want something like