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

StackOverflow https://stackoverflow.com/questions/8155665

  •  02-03-2021
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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

something like

from django.core.management import call_command
call_command('loaddata', 'myapp')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top