Browse Source

management/commands/testdata.py: NoArgsCommand je deprecated od verze

1.1O, nahrada je BaseCommand
export_seznamu_prednasek
Anet 6 years ago
parent
commit
ee0fd9ac93
  1. 11
      seminar/management/commands/testdata.py

11
seminar/management/commands/testdata.py

@ -4,7 +4,7 @@ import datetime
import os import os
import random 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.core.management import call_command
from django.conf import settings from django.conf import settings
@ -14,7 +14,7 @@ import django.contrib.auth
User = django.contrib.auth.get_user_model() User = django.contrib.auth.get_user_model()
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Clear database and load testing data." help = "Clear database and load testing data."
def handle_noargs(self, **options): def handle_noargs(self, **options):
@ -26,9 +26,10 @@ class Command(NoArgsCommand):
call_command('migrate', noinput=True) call_command('migrate', noinput=True)
self.stdout.write('Vytvarim uzivatele "admin" (heslo "admin") a pseudo-nahodna data ...') self.stdout.write('Vytvarim uzivatele "admin" (heslo "admin") a pseudo-nahodna data ...')
create_test_data(size=8) create_test_data(size=8)
self.stdout.write('Vytvoreno %d uzivatelu, %d skol, %d resitelu, %d rocniku, %d cisel, %d problemu, %d reseni.' % self.stdout.write('Vytvoreno %d uzivatelu, %d skol, %d resitelu, %d rocniku, %d cisel,
(User.objects.count(), Skola.objects.count(), Resitel.objects.count(), Rocnik.objects.count(), %d problemu, %d reseni.'.format(User.objects.count(), Skola.objects.count(),
Cislo.objects.count(), Problem.objects.count(), Reseni.objects.count())) Resitel.objects.count(), Rocnik.objects.count(), Cislo.objects.count(),
Problem.objects.count(), Reseni.objects.count()))

Loading…
Cancel
Save