Skip to content

Commit 6475013

Browse files
committed
auto add default color value to admin pannel
1 parent 0f6577f commit 6475013

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

chat/apps.py

+8
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ class ChatConfig(AppConfig):
55
default_auto_field = 'django.db.models.BigAutoField'
66
name = 'chat'
77
verbose_name = "گفتگو"
8+
9+
def ready(self):
10+
try:
11+
from .models import Customize
12+
if len(Customize.objects.all()) == 0:
13+
Customize.create_default_fields()
14+
except Exception:
15+
pass

chat/views.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
from django.utils.safestring import mark_safe
77
from django.contrib.auth.decorators import login_required
88
from django.utils.text import slugify
9-
from .models import Chat, Customize
9+
from .models import Chat
1010

1111

1212
def index(request: object):
13-
Customize.create_default_fields()
1413
user = request.user
1514
context = {
1615
'best_groups': Chat.best_group(),

0 commit comments

Comments
 (0)