Search code examples
djangodjango-managers

Is there a way to call generic managers (e.g. syncdb, flush) from custom managers in django?


For testing purposes, I'm writing a custom manager to reset the whole database, and repopulate certain tables with default fields. At the moment, I do this by calling mange.py flush, followed by manage.py loaddata, followed by the custom manager (that does some fancier stuff). I'd like to bring those all inside a single custom manager.

Is there a way to call generic managers (e.g. flush, loaddata) from my custom manager?


Solution

  • are you talking about management commands? (different to managers)

    something like

    from django.core.management import call_command
    call_command('loaddata', 'myapp')