Skip to content

Commit

Permalink
avoid generating migrations based on settings.LANGUAGE (#186)
Browse files Browse the repository at this point in the history
* avoid generating migrations based on settings

* fixing flake8

* added migration reflecting model changes

* preparation for merge with other incoming migrations
  • Loading branch information
vasekch authored Sep 24, 2023
1 parent 871a5f1 commit 961754c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions djangocms_alias/migrations/0004_alter_aliascontent_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2023-07-26 13:43

from django.db import migrations, models
import django.utils.translation


class Migration(migrations.Migration):

dependencies = [
('djangocms_alias', '0003_auto_20230725_1547'),
]

operations = [
migrations.AlterField(
model_name='aliascontent',
name='language',
field=models.CharField(default=django.utils.translation.get_language, max_length=10),
),
]
5 changes: 4 additions & 1 deletion djangocms_alias/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ class AliasContent(models.Model):
placeholder_slotname = 'content'
language = models.CharField(
max_length=10,
choices=settings.LANGUAGES,
default=get_language,
)

Expand All @@ -278,6 +277,10 @@ class Meta:
verbose_name = _('alias content')
verbose_name_plural = _('alias contents')

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._meta.get_field('language').choices = settings.LANGUAGES

def __str__(self):
return f'{self.name} ({self.language})'

Expand Down

0 comments on commit 961754c

Please sign in to comment.