如何自定义 Django 管理界面中的字段

发布于 2024-09-14 10:20:15 字数 224 浏览 4 评论 0原文

我的 Django 项目中有一个模型,其成员是 char 字段。基本上,该字段中的数据将以逗号分隔值的形式输入。

如果没有对总体目标进行长篇大论的解释,基本上我不想让管理界面使用简单的文本字段,而是希望为表单提供一些自定义 HTML,这样我就可以只使用复选框并组合值提交表单后,我自己将选中的复选框转换为 CSV 字符串。

我在 Google 上找到的大多数 django 定制都没有回答我的特定问题。

I have a model in my Django project with a member which is a char field. Basically data in this field will be entered as comma-separated values.

Without a long-winded explanation of what the overall goal of this is, basically rather than having the admin interface use a simple text field, I'd rather have have some custom HTML for the form so I can just use checkboxes and assemble the values of the checked boxes into a CSV string myself once the form is submitted.

Most of the django customization I was able to find on Google didn't answer my particular problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2024-09-21 10:20:15

如果我正确理解你的问题,我认为你想搜索编写自定义小部件。也许从这里开始: http://docs.djangoproject.com/en/dev/topics /表格/

If I understand your question correctly I think you want to search for writing custom widgets. Perhaps start here: http://docs.djangoproject.com/en/dev/topics/forms/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文