Opraveno organizuje od a organizuje do
This commit is contained in:
parent
6706bebdb7
commit
f054d9785a
3 changed files with 38 additions and 2 deletions
|
@ -219,7 +219,7 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='organizator',
|
model_name='organizator',
|
||||||
name='organizuje_od',
|
name='organizuje_od',
|
||||||
field=models.DateTimeField(default='1900-01-01T00:00:00', verbose_name='Organizuje od'),
|
field=models.DateTimeField(null=True,blank=True, verbose_name='Organizuje od'),
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='organizator',
|
model_name='organizator',
|
||||||
|
|
36
seminar/migrations/0053_organizator_organizuje_od_do.py
Normal file
36
seminar/migrations/0053_organizator_organizuje_od_do.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.20 on 2019-05-16 21:26
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime as dt
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def rok_to_datetime(apps,schema_editor):
|
||||||
|
Organizator = apps.get_model('seminar','Organizator')
|
||||||
|
for o in Organizator.objects.all():
|
||||||
|
rok = o.organizuje_od_roku
|
||||||
|
if rok:
|
||||||
|
o.organizuje_od = dt.datetime(rok,1,1)
|
||||||
|
rok = o.organizuje_do_roku
|
||||||
|
if rok:
|
||||||
|
o.organizuje_do = dt.datetime(rok,12,31)
|
||||||
|
o.save()
|
||||||
|
|
||||||
|
def datetime_to_rok(apps,schema_editor):
|
||||||
|
Organizator = apps.get_model('seminar','Organizator')
|
||||||
|
for o in Organizator.objects.all():
|
||||||
|
o.organizuje_od_roku = o.organizuje_od.year
|
||||||
|
o.organizuje_do_roku = o.organizuje_do.year
|
||||||
|
o.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0052_user_to_organizator'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(rok_to_datetime, datetime_to_rok),
|
||||||
|
]
|
|
@ -467,7 +467,7 @@ class Organizator(SeminarModelBase):
|
||||||
editable=False
|
editable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
organizuje_od = models.DateTimeField('Organizuje od', blank=False, null=False, default="1900-01-01T00:00:00")
|
organizuje_od = models.DateTimeField('Organizuje od', blank=True, null=True)
|
||||||
|
|
||||||
organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True)
|
organizuje_do = models.DateTimeField('Organizuje do', blank=True, null=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue