39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
# Generated by Django 2.2.4 on 2019-09-23 15:05
|
|
from django.core.validators import EMPTY_VALUES
|
|
from django.db import migrations, models
|
|
|
|
from news.models import News
|
|
|
|
|
|
def migrate_data_forward(apps, schema_editor):
|
|
for instance in News.objects.all():
|
|
if instance.slug in EMPTY_VALUES:
|
|
instance.slug = None
|
|
instance.save(update_fields=['slug'])
|
|
|
|
def migrate_data_backward(apps, schema_editor):
|
|
pass
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('news', '0010_news_slug'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AlterField(
|
|
model_name='news',
|
|
name='slug',
|
|
field=models.SlugField(null=True, verbose_name='News slug'),
|
|
),
|
|
migrations.RunPython(
|
|
migrate_data_forward,
|
|
migrate_data_backward,
|
|
),
|
|
migrations.AlterField(
|
|
model_name='news',
|
|
name='slug',
|
|
field=models.SlugField(null=True, unique=True, verbose_name='News slug'),
|
|
),
|
|
]
|