diff --git a/adminpanelapp/admin.py b/adminpanelapp/admin.py index e066c49..781ff8b 100644 --- a/adminpanelapp/admin.py +++ b/adminpanelapp/admin.py @@ -14,6 +14,7 @@ class OrdersAdmin(admin.ModelAdmin): actions =['send_message'] exclude = ['orderAccess', 'userID', 'orderPhoto', 'orderPhotoPay'] + def show_photo(self, obj): html = obj.get_photo_html() return mark_safe(html) diff --git a/adminpanelapp/models.py b/adminpanelapp/models.py index 4f039a1..2c2bcbf 100644 --- a/adminpanelapp/models.py +++ b/adminpanelapp/models.py @@ -14,7 +14,7 @@ class Orders(models.Model): orderName = models.CharField(max_length=100, verbose_name='наименование', null=True) orderDesc = models.TextField(verbose_name='описание', null=True) orderPhoto = models.ImageField(verbose_name='фото', null=True) - orderPhotoPay = models.ImageField(upload_to='photo/', verbose_name='чек') + orderPhotoPay = models.ImageField(verbose_name='чек') orderAddress = models.CharField(max_length=100, verbose_name='адрес доставки', blank=True, null=True) orderAccess = models.CharField(max_length=100, verbose_name='доступ', blank=True, null=True) orderCreateDateTime = models.DateTimeField(auto_now_add=True, null=True, verbose_name='дата и время создания') @@ -135,6 +135,7 @@ class Orders(models.Model): """ return html + class Meta: verbose_name_plural = 'Заказы' diff --git a/adminpanelapp/views.py b/adminpanelapp/views.py index 28bfc5e..473a886 100644 --- a/adminpanelapp/views.py +++ b/adminpanelapp/views.py @@ -3,14 +3,14 @@ from django.http import HttpResponseRedirect import requests from django.urls import reverse from django.shortcuts import render -from bot_sys.config import g_telegram_bot_api_token +from bot_sys.config import GetTelegramBotApiToken def send_telegram_message(request, chat_id): if request.method == 'POST': message = request.POST.get('message') - bot_token = g_telegram_bot_api_token + bot_token = GetTelegramBotApiToken() url = f'https://api.telegram.org/bot{bot_token}/sendMessage?text={message}&chat_id={chat_id}' response = requests.get(url)