-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds migration to add slug to the News model.
- Loading branch information
1 parent
2dff578
commit e4833e2
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
physionet-django/notification/migrations/0008_news_slug.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 4.1.10 on 2023-11-29 19:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def set_default_slugs(apps, schema_editor): | ||
News = apps.get_model('notification', 'News') | ||
for news in News.objects.all(): | ||
news.slug = str(news.id) | ||
news.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notification", "0007_auto_20220221_0332"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="news", | ||
name="slug", | ||
field=models.SlugField(max_length=100, null=True), | ||
), | ||
migrations.RunPython(set_default_slugs, reverse_code=migrations.RunPython.noop), | ||
] |
18 changes: 18 additions & 0 deletions
18
physionet-django/notification/migrations/0009_alter_news_slug.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 4.1.10 on 2023-11-29 20:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("notification", "0008_news_slug"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="news", | ||
name="slug", | ||
field=models.SlugField(max_length=100, unique=True), | ||
preserve_default=False, | ||
), | ||
] |