Created
March 3, 2016 20:13
-
-
Save klebercode/8813a00004843bbe515f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Generated by Django 1.9 on 2016-03-03 20:09 | |
from __future__ import unicode_literals | |
from django.db import migrations, models | |
from django.template.defaultfilters import slugify | |
def create_portfolio_slug(apps, schema_editor): | |
Portfolio = apps.get_model("core", "Portfolio") | |
for portfolio in Portfolio.objects.all(): | |
portfolio.slug = slugify(portfolio.pk) | |
portfolio.save() | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('core', '0003_auto_20160303_1928'), | |
] | |
operations = [ | |
migrations.AddField( | |
model_name='portfolio', | |
name='slug', | |
field=models.SlugField(default=0), | |
preserve_default=False, | |
), | |
migrations.RunPython(create_portfolio_slug), | |
migrations.AlterField( | |
model_name='portfolio', | |
name='slug', | |
field=models.SlugField(default=0, unique=True, verbose_name='URL no site'), | |
), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment