Prepend "operation_" to the data migration functions for clear purpose. Add keyword arguments to the RunPython migration opration. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
24 lines
577 B
Python
24 lines
577 B
Python
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations
|
|
from django.template.defaultfilters import slugify
|
|
|
|
|
|
def operation_assign_slugs(apps, schema_editor):
|
|
Index = apps.get_model('document_indexing', 'Index')
|
|
|
|
for index in Index.objects.using(schema_editor.connection.alias).all():
|
|
index.slug = slugify(index.label)
|
|
index.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('document_indexing', '0005_index_slug'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(code=operation_assign_slugs),
|
|
]
|