Skip to content

Commit e236b36

Browse files
committed
fix: icon_name model field choices lazy loading
1 parent 6c1370e commit e236b36

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

apps/html_template_editor/models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# from django.contrib.auth import get_user_model
66
from django.contrib.postgres.fields import JSONField
77
from django.db import models
8+
from django.utils.functional import lazy
89
from django.utils.html import mark_safe
910
from django.utils.translation import ugettext_lazy as _
1011

@@ -166,7 +167,7 @@ class Meta:
166167

167168
icon_name = models.CharField(
168169
verbose_name=_("Icon name"),
169-
choices=get_social_media_icons_names(),
170+
choices=(),
170171
max_length=20,
171172
null=True,
172173
blank=True,
@@ -177,6 +178,12 @@ class Meta:
177178
blank=True,
178179
)
179180

181+
def __init__(self, *args, **kwargs):
182+
super().__init__(*args, **kwargs)
183+
self._meta.get_field('icon_name').choices = lazy(
184+
get_social_media_icons_names,
185+
)()
186+
180187
def __str__(self):
181188
return f'{self.icon_name} : {self.url}'
182189

0 commit comments

Comments
 (0)