35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
# Generated by Django 3.1.1 on 2021-03-03 09:43
|
|
|
|
from django.db import migrations, models
|
|
from django.utils.text import slugify
|
|
|
|
def create_slugs(apps, schema_editor):
|
|
for model in ('Ensemble', 'Project'):
|
|
M = apps.get_model('interface', model)
|
|
for instance in M.objects.all():
|
|
if instance.slug == '':
|
|
instance.slug = slugify(instance.name)
|
|
instance.save()
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('interface', '0021_project_description'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='ensemble',
|
|
name='slug',
|
|
field=models.SlugField(default='', editable=False, max_length=100),
|
|
preserve_default=False,
|
|
),
|
|
migrations.AddField(
|
|
model_name='project',
|
|
name='slug',
|
|
field=models.SlugField(default='', editable=False, max_length=100),
|
|
preserve_default=False,
|
|
),
|
|
migrations.RunPython(create_slugs)
|
|
]
|