开发者

django multiple select in admin change-list

开发者 https://www.devze.com 2023-01-21 01:50 出处:网络
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 selec

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?

T开发者_运维百科hanks,


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,)







0

精彩评论

暂无评论...
验证码 换一张
取 消