Hello smart people of SO. I am trying to make a dependent Django admin form. Where if a user selects Channel as a sku type, then he just has to add service category and product category and remaining fields become inactive for him and it has null values stored in them. If a user select direct then all fields become active and he can add data into all fields. In a nutshell, I am looking for column activity based on the values in the sku type field. Not sure if we can do it in Django at this point or not. I am using Django 1.10.
I have a model of my app as following
from django.db import models
from decimal import Decimal
class Sku(models.Model):
sku_type = (
('Channel', 'Channel'),
('Direct', 'Direct'),
('Warranty', 'Warranty'),
('abc', 'abc'),
)
sku_type = models.CharField("SKU Type", choices=sku_type, default='Channel', max_length=20)
sku = models.CharField("SKU", primary_key=True, max_length=20)
date_added = models.DateTimeField("Date when Added", auto_now=False, auto_now_add=True)
date_updated = models.DateTimeField("Last Updated Date", auto_now=True, auto_now_add=False)
service_category = models.CharField(max_length=200, blank=True, null=True)
product_category = models.CharField(max_length=200, blank=True, null=True)
product_description = models.TextField(blank=True, null=True)
sap_description = models.TextField(blank=True, null=True)
def __str__(self):
return self.sku