Skip to content

Commit 63937dc

Browse files
committed
add customize model
1 parent 1d43232 commit 63937dc

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

chat/admin.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""chat admin
22
"""
3+
from csv import list_dialects
34
from datetime import datetime
45
from django.contrib import admin
56
from django.utils.html import format_html
6-
from .models import Message, Chat
7+
from .models import Message, Chat, Customize
78

89

910
class MessageAdmin(admin.ModelAdmin):
@@ -47,5 +48,10 @@ def time(self, model: Chat):
4748
messages.short_description = "تعداد پیام ها"
4849

4950

51+
class CustomizeAdmin(admin.ModelAdmin):
52+
list_display = ("name", "color")
53+
54+
5055
admin.site.register(Message, MessageAdmin)
5156
admin.site.register(Chat, ChatAdmin)
57+
admin.site.register(Customize, CustomizeAdmin)

chat/models.py

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.db import models
77
from django.contrib.auth.models import User
88
from django.utils.crypto import get_random_string
9+
from colorfield.fields import ColorField
910

1011

1112
def unique_string():
@@ -154,3 +155,18 @@ def __str__(self):
154155
class Meta:
155156
verbose_name_plural = "پیام ها"
156157
verbose_name = "پیام"
158+
159+
160+
class Customize(models.Model):
161+
name = models.CharField(
162+
max_length=128,
163+
null=False, blank=False,
164+
verbose_name="قسمت")
165+
color = ColorField(default="#27ae60")
166+
167+
def __str__(self):
168+
return self.name
169+
170+
class Meta:
171+
verbose_name_plural = "شخصی سازی"
172+
verbose_name = "بخش"

core/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'auth',
5050
'channels',
5151
'rest_framework',
52+
'colorfield',
5253
]
5354

5455
MIDDLEWARE = [

0 commit comments

Comments
 (0)