Django 在管理更改列表中进行多项选择

发布于 2024-09-29 16:05:31 字数 157 浏览 1 评论 0原文

我们的产品模型可以有多个营销活动。我们的客户经常更改这些营销活动,并且通常针对多种产品。因此,我们现在需要的似乎是我们需要在产品模型的更改列表上显示一个多选小部件,我们的客户可以在其中轻松更改活动。

对此有什么想法吗?也许还有另一种方式来实现这种 UI 交互?

谢谢,

Our product model can have multiple campaigns. Our customers change these campaigns frequently and generally on multiple products. So what we need right now seems that we need to show a multiple select widget on a change-list of Product model where our customers can easily change the campaigns.

Any idea on this? Maybe another way to achieve this kind of UI interaction?

Thanks,

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

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

发布评论

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

评论(1

酷遇一生 2024-10-06 16:05:31

假设您有一个产品模型,


class Product(models.Model):
  name=models.CharField(max_length=20)
  cost=models.DecimalField(max_length=10)



您可以对管理员的 Modeladmin 进行子类化以显示产品的列表显示,或者您可以为产品创建一个自定义模型表单,您可以在产品的管理员中调用该模型


from django.contrib import admin
from django import forms

class PropertyInline(admin.TabularInine):
   model=Property
   extra=1

class PropertyForm(admin.ModelAdmin):
   inlines=(PropertyInline,)







say you have a product model


class Product(models.Model):
  name=models.CharField(max_length=20)
  cost=models.DecimalField(max_length=10)



you can subclass the admin's Modeladmin to show a list display for the products or you can do a custom modelform for the product which you can call in the product's admin


from django.contrib import admin
from django import forms

class PropertyInline(admin.TabularInine):
   model=Property
   extra=1

class PropertyForm(admin.ModelAdmin):
   inlines=(PropertyInline,)







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