2021-05-19 17:01:28 -04:00
|
|
|
from django.db import migrations, models
|
|
|
|
from django.utils.text import slugify
|
|
|
|
|
|
|
|
|
|
|
|
def slugify_name(apps, schema_editor):
|
2022-02-14 12:44:42 -05:00
|
|
|
Tool = apps.get_model("tasks", "tool")
|
2021-05-19 17:01:28 -04:00
|
|
|
for tool in Tool.objects.all():
|
|
|
|
tool.slug = slugify(tool.name)
|
2022-02-14 12:44:42 -05:00
|
|
|
tool.save(update_fields=["slug"])
|
|
|
|
|
2021-05-19 17:01:28 -04:00
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
2022-02-14 12:44:42 -05:00
|
|
|
("tasks", "0001_initial"),
|
2021-05-19 17:01:28 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AddField(
|
2022-02-14 12:44:42 -05:00
|
|
|
model_name="tool",
|
|
|
|
name="slug",
|
2021-05-19 17:01:28 -04:00
|
|
|
field=models.SlugField(blank=True, null=True, unique=True),
|
|
|
|
),
|
|
|
|
migrations.RunPython(slugify_name),
|
|
|
|
migrations.AlterField(
|
2022-02-14 12:44:42 -05:00
|
|
|
model_name="tool",
|
|
|
|
name="slug",
|
2021-05-19 17:01:28 -04:00
|
|
|
field=models.SlugField(unique=True),
|
2022-02-14 12:44:42 -05:00
|
|
|
),
|
2021-05-19 17:01:28 -04:00
|
|
|
]
|