【发布时间】:2017-08-19 02:12:43
【问题描述】:
models.py:
class Plan(models.Model):
PLAN_TYPE_CHOICES = (
('global', 'Global'),
('user specific', 'User Specific'),
)
name_of_plan = models.CharField(max_length=256, null=False, blank=False)
number_of_months = models.IntegerField(db_index=True)
type_of_plan = models.CharField(choices=PLAN_TYPE_CHOICES)
specific_users = models.ManyToManyField(User, db_index=True)
admin.py
from django.contrib import admin
from .models import Plan
class PlanAdmin(admin.ModelAdmin):
model = Plan
admin.site.register(Plan, PlanAdmin)
在管理页面中,我有 type_of_plan 选项:“全局”、“用户特定”...当我选择“用户特定”值时,我需要显示 specific_users 字段而当我选择“全局”值时,我需要隐藏 specific_users字段...我该怎么做?
【问题讨论】:
标签: jquery django django-models django-forms django-admin