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)
In admin page I have type_of_plan with choices: "Global", "User Specific"... When I select "User Specific" value I need to show specific_users field And when I select "Global" value I need to hide specific_users field... How can I do it?