表thumbnail_kvstore不存在 [英] Table thumbnail_kvstore doesn't exist
问题描述
我无法在缩略图中显示缩略图。我收到这个错误:
I can't get the thumbnail displayed in my template. I get this error:
django.db.utils.ProgrammingError:(1146,ia_website.thumbnail_kvstore不存在 )
django.db.utils.ProgrammingError: (1146, "Table 'ia_website.thumbnail_kvstore' doesn't exist")
- 已安装sorl_thumbnail-12.3
- 我正在使用MariaDB 10.1.11
- 我没有执行的迁移
- 如果我不使用缩略图标签,我可以看到图片
- Installed sorl_thumbnail-12.3
- I'm using MariaDB 10.1.11
- I have no migration that are not executed
- I can see the image if I don't use the 'thumbnail' tag
-
在settings.py:
In settings.py:
这是我做的
INSTALLED_APPS = [
...
'sorl.thumbnail',
]
THUMBNAIL_DEBUG = TRUE
在models.py
In models.py
import sorl
...
image = sorl.thumbnail.ImageField(upload_to='thumbnails', null=True)
在我的模板中
In my template
{% thumbnail content.image "237x110" as im %}
<img src="{{ im.url }}">
{% endthumbnail %}
推荐答案
经过一些研究,它看起来像PyPI和Github上的sorl-thumbnail版本 12.3
不同!
So after some research, it looks like the version 12.3
of sorl-thumbnail on PyPI and Github are different!
如果您直接从 PyPI - 你会发现包不包含任何迁移。 这是表中不存在的原因,即使您已经运行所有迁移。
If you download the source directly from PyPI - you will find that the package doesn't contain any migrations. This is the reason the table doesn't exist even though you've run all the migrations.
在Github上,版本 > 12.3
绝对存在
On Github, the migration file for version 12.3
definitely exists.
您有三个选项:
- 使用
./ manage.py syncdb
创建表(仅当您运行Django 1.8或更低版本) - 从Github直接安装版本
12.3
- 使用版本
12.4a1
包括迁移的thumbnail
- Create the table using
./manage.py syncdb
(only if you're running Django 1.8 or below) - Install directly from Github for version
12.3
- Use version
12.4a1
of sorl-thumbnail which includes migrations
您可以直接从Github安装如下:
You can install from Github directly as follows:
pip install git+git://github.com/mariocesar/sorl-thumbnail@v12.3
sorl-thumbnail版本12.3支持Django版本1.8,syncdb命令仍然存在。如果您正在运行Django 1.8或更低版本,则可以通过运行
sorl-thumbnail version 12.3 supports up to Django version 1.8, where the syncdb command still exists. If you're running Django 1.8 or lower, you can create the missing table by running
python manage.py syncdb
这篇关于表thumbnail_kvstore不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!