from django.core.management.base import CommandError
from daemon_command import DaemonCommand
from myapp.models import MyModel


class Command(DaemonCommand):
    help = 'Does some magical work'

def loop_callback(self, *args, **options):
    """ Do your work here """
self.stdout.write('There are {} things!'.format(MyModel.objects.count()))
Использование моделей Django во внешнем скрипте Python