Skip to content

Commit 961754c

Browse files
authored
avoid generating migrations based on settings.LANGUAGE (#186)
* avoid generating migrations based on settings * fixing flake8 * added migration reflecting model changes * preparation for merge with other incoming migrations
1 parent 871a5f1 commit 961754c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 3.2.20 on 2023-07-26 13:43
2+
3+
from django.db import migrations, models
4+
import django.utils.translation
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('djangocms_alias', '0003_auto_20230725_1547'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='aliascontent',
16+
name='language',
17+
field=models.CharField(default=django.utils.translation.get_language, max_length=10),
18+
),
19+
]

djangocms_alias/models.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ class AliasContent(models.Model):
268268
placeholder_slotname = 'content'
269269
language = models.CharField(
270270
max_length=10,
271-
choices=settings.LANGUAGES,
272271
default=get_language,
273272
)
274273

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

280+
def __init__(self, *args, **kwargs):
281+
super().__init__(*args, **kwargs)
282+
self._meta.get_field('language').choices = settings.LANGUAGES
283+
281284
def __str__(self):
282285
return f'{self.name} ({self.language})'
283286

0 commit comments

Comments
 (0)