Django
3
Вклад в тег
from django.utils.timezone import now
from django.utils.timezone import now, pytz
user_timezone = pytz.timezone(user.timezone or settings.TIME_ZONE)
now().astimezone(user_timezone)
from datetime import datetime
from django.utils.timezone import pytz
user_timezone = pytz.timezone(user.timezone or settings.TIME_ZONE)
user_timezone.localize(now())
TIME_ZONE = 'Europe/Moscow'
USE_TZ = True
object_list = list(MyModel.objects.raw(...))
from django.db.models.query import prefetch_related_objects
object_list = list(MyModel.objects.raw(...))
prefetch_related_objects(raw_qs, ['fk_field', 'another_fk_field', ...])