Testdata command: tabs
This commit is contained in:
parent
81c561a1a8
commit
fbf288039c
1 changed files with 14 additions and 14 deletions
|
@ -15,21 +15,21 @@ User = django.contrib.auth.get_user_model()
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Clear database and load testing data."
|
help = "Clear database and load testing data."
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
assert settings.DEBUG == True
|
assert settings.DEBUG == True
|
||||||
dbfile = settings.DATABASES['default']['NAME']
|
dbfile = settings.DATABASES['default']['NAME']
|
||||||
if os.path.exists(dbfile):
|
if os.path.exists(dbfile):
|
||||||
os.rename(dbfile, dbfile + '.old')
|
os.rename(dbfile, dbfile + '.old')
|
||||||
self.stderr.write('Stara databaze prejmenovana na "%s"' % (dbfile + '.old'))
|
self.stderr.write('Stara databaze prejmenovana na "%s"' % (dbfile + '.old'))
|
||||||
call_command('migrate', no_input=True)
|
call_command('migrate', no_input=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 {} uzivatelu, {} skol, {} resitelu, {} rocniku, {} cisel,'
|
self.stdout.write('Vytvoreno {} uzivatelu, {} skol, {} resitelu, {} rocniku, {} cisel,'
|
||||||
' {} problemu, {} reseni.'.format(User.objects.count(), Skola.objects.count(),
|
' {} problemu, {} reseni.'.format(User.objects.count(), Skola.objects.count(),
|
||||||
Resitel.objects.count(), Rocnik.objects.count(), Cislo.objects.count(),
|
Resitel.objects.count(), Rocnik.objects.count(), Cislo.objects.count(),
|
||||||
Problem.objects.count(), Reseni.objects.count()))
|
Problem.objects.count(), Reseni.objects.count()))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue