标签:
django
python

django 3.1报错 relation "my_cache_table" does not exist LINE 1: SELECT "cache_key", "value", "expires" FROM "my_cache_table"

提问于:2 个月前 ( )最后更新于:2 个月前 (2020-09-19 19:11:09)提问人:豆瓣123455


django 3.1, python 3.8

我新建了一个数据库,把以前的代码拷贝过来,运行就会出现这个错误

settings.py

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
        'LOCATION': 'my_cache_table',
    }
}

报错信息:
ProgrammingError at /auth/ relation "my_cache_table" does not exist LINE 1: SELECT "cache_key", "value", "expires" FROM "my_cache_table"...

1个回答

free
free

你这个是数据库里没有这个表 my_cache_table

执行 python manage.py createcachetable

参考django官方文档:
https://docs.djangoproject.com/en/3.1/topics/cache/#database-caching

2020-09-19 19:14:50