management/commands/testdata.py: NoArgsCommand je deprecated od verze
1.1O, nahrada je BaseCommand
This commit is contained in:
parent
04a53b901c
commit
ee0fd9ac93
1 changed files with 6 additions and 5 deletions
|
@ -4,7 +4,7 @@ import datetime
|
|||
import os
|
||||
import random
|
||||
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -14,7 +14,7 @@ import django.contrib.auth
|
|||
User = django.contrib.auth.get_user_model()
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Clear database and load testing data."
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
|
@ -26,9 +26,10 @@ class Command(NoArgsCommand):
|
|||
call_command('migrate', noinput=True)
|
||||
self.stdout.write('Vytvarim uzivatele "admin" (heslo "admin") a pseudo-nahodna data ...')
|
||||
create_test_data(size=8)
|
||||
self.stdout.write('Vytvoreno %d uzivatelu, %d skol, %d resitelu, %d rocniku, %d cisel, %d problemu, %d reseni.' %
|
||||
(User.objects.count(), Skola.objects.count(), Resitel.objects.count(), Rocnik.objects.count(),
|
||||
Cislo.objects.count(), Problem.objects.count(), Reseni.objects.count()))
|
||||
self.stdout.write('Vytvoreno %d uzivatelu, %d skol, %d resitelu, %d rocniku, %d cisel,
|
||||
%d problemu, %d reseni.'.format(User.objects.count(), Skola.objects.count(),
|
||||
Resitel.objects.count(), Rocnik.objects.count(), Cislo.objects.count(),
|
||||
Problem.objects.count(), Reseni.objects.count()))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue