Django模型中的关键字字段 [英] Keywords Field in Django Model

查看:40
本文介绍了Django模型中的关键字字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Django的初学者.在我的模型中,我有一个名为关键字的字段,我想在其中存储关键字(以逗号分隔).

I'm beginner in Django. In my model I have a Field named keywords that I want to store keywords in it (separated by comma).

用户可以输入复合关键字"learn Django" "Django model-Fields" ,并且我还想设置一个每个关键字的max_length .还有一个 max?个关键字!

A user may enter a compound keyword "learn Django" or "Django model-Fields", and also I want to have the possibility to set a max_length for every keyword. And a max ? of keywords!

请问我该怎么做?

推荐答案

您可以使用 django taggit 或类似的应用.使用现有的应用程序还意味着您不必重复他们已经完成的工作,例如生成类似项目"查询集.

You can add this feature to any model using django taggit or a similar app. Using an existing app also means you don't have to repeat the work they've already done, such as producing a 'similar items' queryset.

这篇关于Django模型中的关键字字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆