I have a model
MenuResource which has 3 types: resource with no link, resource with internal page, resource with custom link.
I would like to use Django Admin to create
But, depends on the
MenuResource type, different attribute should be filled - in case
internal_url_name attribute should be filled and in case
CUSTOM LINK then
external_hyperlink should be filled.
Is there a way I could quickly solve this using Django Admin - so after user selects specific
resource_type, A) specific attribute should be presented for him to fill it or B) specific attribute field should be disabled/enabled. How could I do that using Django Admin - both ways A) and B) are fine for me ?
class MenuResourceChoice(models.TextChoices): R0 = 'R0', 'NO LINK' R1 = 'R1', 'INTERNAL PAGE' R2 = 'R2', 'CUSTOM LINK' class MenuResource(models.Model): resource_type = models.CharField(max_length=2, choices=MenuResourceChoice.choices, default=MenuResourceChoice.R0) internal_url_name = models.CharField(max_length=30) external_hyperlink = models.URLField()
EDIT 1: Also if I have pre-defined buttons to set the type before the form is presented to user - so buttons like “Create Custom Link” and “Create Internal Page” and then depending which button you click, different form is presented to you - this solution is also fine for me if possible.