Django_tagging (v0.3/pre):配置问题
我试图在我的一个项目中使用 django 标记并遇到一些错误。
我可以在 shell 中使用标签,但无法从管理界面分配它们。
我想要做的是将“标签”功能添加到模型中,并从管理界面添加/删除标签。
为什么“标签”是由 shell 看到的,而不是由“管理”界面看到的?到底是怎么回事?
Model.py:Admin.py
import tagging
class Department(models.Model):
tags = TagField()
:
class DepartmentAdmin(admin.ModelAdmin):
list_display = ('name', 'tags') --> works
....
fields = ['name', 'tags'] --> throws error
错误
OperationalError at /admin/department/1/
(1054, "Unknown column 'schools_department.tags' in 'field list'")
I am trying to use the django-tagging in one of my project and run into some errors.
I can play with tags in the shell but couldn't assign them from admin interface.
What I want to do is add "tag" functionality to a model and add/remove tags from Admin interface.
Why is it the "tags" are seen by shell and not by "admin" interface? What is going on?
Model.py:
import tagging
class Department(models.Model):
tags = TagField()
Admin.py:
class DepartmentAdmin(admin.ModelAdmin):
list_display = ('name', 'tags') --> works
....
fields = ['name', 'tags'] --> throws error
Error
OperationalError at /admin/department/1/
(1054, "Unknown column 'schools_department.tags' in 'field list'")
I looked at the docs and couldn't find further information
Useful Tips
Overview Txt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TagField 需要模型上的实际数据库列;它使用它来缓存输入的标签。如果将 TagField 添加到已有数据库表的模型中,则需要将该列添加到数据库表中,就像添加任何其他类型的字段一样。使用架构迁移工具(如 South 或 django-evolution)或手动运行适当的 SQL ALTER TABLE 命令。
The TagField requires an actual database column on your model; it uses this to cache the tags as entered. If you add a TagField to a model that already has a database table, you will need to add the column to the database table, just as with adding any other type of field. Either use a schema migration tool (like South or django-evolution) or run the appropriate SQL ALTER TABLE command manually.