News slug, disable null, remove editable
This commit is contained in:
parent
62fbded6de
commit
c9bf83fba7
21
apps/news/migrations/0014_auto_20190927_0845.py
Normal file
21
apps/news/migrations/0014_auto_20190927_0845.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 2.2.4 on 2019-09-27 08:45
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def fill_slug(apps,schemaeditor):
|
||||
News = apps.get_model('news', 'News')
|
||||
for news in News.objects.all():
|
||||
if news.slug is None:
|
||||
news.slug = f'Slug {news.id}'
|
||||
news.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0013_auto_20190924_0806'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(fill_slug, migrations.RunPython.noop)
|
||||
]
|
||||
18
apps/news/migrations/0015_auto_20190927_0853.py
Normal file
18
apps/news/migrations/0015_auto_20190927_0853.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.2.4 on 2019-09-27 08:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('news', '0014_auto_20190927_0845'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='news',
|
||||
name='slug',
|
||||
field=models.SlugField(unique=True, verbose_name='News slug'),
|
||||
),
|
||||
]
|
||||
|
|
@ -63,8 +63,8 @@ class News(BaseAttributes, TranslatedFieldsMixin):
|
|||
start = models.DateTimeField(verbose_name=_('Start'))
|
||||
end = models.DateTimeField(blank=True, null=True, default=None,
|
||||
verbose_name=_('End'))
|
||||
slug = models.SlugField(unique=True, max_length=50, null=True,
|
||||
verbose_name=_('News slug'), editable=True,)
|
||||
slug = models.SlugField(unique=True, max_length=50,
|
||||
verbose_name=_('News slug'))
|
||||
playlist = models.IntegerField(_('playlist'))
|
||||
is_publish = models.BooleanField(default=False,
|
||||
verbose_name=_('Publish status'))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user