Tomas "Jethro" Pokorny
6 years ago
3 changed files with 38 additions and 2 deletions
@ -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), |
|||
] |
Loading…
Reference in new issue