我有模特团体和会员资格。在管理页面中,我想显示具有特定角色的组成员。怎么做?默认情况下,管理员现在向我显示组的所有成员。
models.py :
class Group(models.Model):
members = models.ManyToManyField(User, through='Membership',)
class Membership (models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE,)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
role = models.CharField(max_length=20, choices=ROLE_CHOICES,)
admin.py :
class MembershipInline(admin.TabularInline):
model = Membership
form = MembershipAdminForm
extra = 1
max_num = 1
class MembershipAdmin(admin.ModelAdmin):
inlines = (MembershipInline,)
admin.site.register(Group, MembershipAdmin)
答案 0 :(得分:1)
每the documentation,TabularInline shares methods with ModelAdmin包括List<Karta> nova = new List<Karta>();
public Form2(List<Karta> input)
{
nova = input;
}
}
:
get_queryset()