0.12.20 timezone in chat messages
This commit is contained in:
@@ -288,6 +288,9 @@ def send_msg(data):
|
|||||||
|
|
||||||
def get_chat_page_content_html(request, receiver_id=None):
|
def get_chat_page_content_html(request, receiver_id=None):
|
||||||
from AuthApp.models import User
|
from AuthApp.models import User
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
now = timezone.now()
|
||||||
|
|
||||||
msgs = []
|
msgs = []
|
||||||
try:
|
try:
|
||||||
|
|||||||
15
GeneralApp/tz_middelware.py
Normal file
15
GeneralApp/tz_middelware.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import pytz
|
||||||
|
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
class TimezoneMiddleware:
|
||||||
|
def __init__(self, get_response):
|
||||||
|
self.get_response = get_response
|
||||||
|
|
||||||
|
def __call__(self, request):
|
||||||
|
tzname = request.session.get('django_timezone')
|
||||||
|
if tzname:
|
||||||
|
timezone.activate(pytz.timezone(tzname))
|
||||||
|
else:
|
||||||
|
timezone.deactivate()
|
||||||
|
return self.get_response(request)
|
||||||
@@ -126,6 +126,7 @@ MIDDLEWARE = [
|
|||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'AuthApp.middleware.ResponseInterceptionMiddleware',
|
'AuthApp.middleware.ResponseInterceptionMiddleware',
|
||||||
|
'GeneralApp.tz_middelware.TimezoneMiddleware',
|
||||||
|
|
||||||
"allauth.account.middleware.AccountMiddleware",
|
"allauth.account.middleware.AccountMiddleware",
|
||||||
]
|
]
|
||||||
@@ -220,11 +221,11 @@ TIME_ZONE = 'Europe/Minsk'
|
|||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
# USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = False
|
# USE_TZ = False
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||||
|
|||||||
Reference in New Issue
Block a user