Я хочу просмотреть архив со следующим URL:
example.com/2019/06
example.com/2018/11
Однако при доступе
django.db.utils.ProgrammingError: (1146, "Table 'mysql.time_zone' doesn't exist")
возвращается.
Если я изменю USE_TZ
в settings.py на False
, ошибка исчезнет, и я смогу получить к ней доступ в обычном режиме, но я не хочу иметь значение False.
urls.py
path('<int:year>/<int:month>', ArchiveList.as_view(month_format='%m'), name='archive_list'),
views.py
class ArchiveList(MonthArchiveView):
model = BlogPost
template_name = 'blog/post_list.html'
date_field = 'created_date'
month_format = '%m'
year_format = '%Y'
allow_future = True
def get_month(self):
month = super(ArchiveList, self).get_month()
return month
def get_year(self):
year = super(ArchiveList, self).get_year()
return year
models.py
class BlogPost(models.Model, HitCountMixin):
author = models.ForeignKey('auth.User', blank=False, on_delete=models.CASCADE)
main_image = FileBrowseField("mainimage", max_length=200, directory="media/uploads/thumbnail/",
extensions=[".jpg", ".png"], blank=False, null=True)
category = models.ForeignKey('SubCategory', verbose_name='category', default=3, on_delete=models.PROTECT)
title = models.CharField(max_length=33, blank=False)
description = models.TextField(max_length=108, default='', blank=False)
content = FroalaField(default='', blank=False, null=False)
created_date = models.DateTimeField(default=timezone.now, blank=False)
published_date = models.DateTimeField(blank=True, null=True)
is_public = models.BooleanField(default=True)
hit_count_generic = GenericRelation(
HitCount, object_id_field='object_pk',
related_query_name='hit_count_generic_relation')
settings.py
USE_I18N = True
USE_L10N = True
USE_TZ = True
Что мне теперь делать?