I'm working on a Django project right now and when adding a Right model I want the form to look different depending on what is chosen in the attribute 'type'. Here's my code:
models.py
class Right(models.Model):
RIGHT_TYPE_CHOICE = (
('NR', 'Normal right'),
('TR', 'Timed right'),
('ToR', 'Timeout right'),
)
name = models.CharField(max_length=200, help_text="The name of the right. What does it mean?")
description = models.CharField(max_length=200, blank=True, help_text="Description of the right. Not required.")
type = models.CharField(max_length=100, choices=RIGHT_TYPE_CHOICE, help_text="The predefined type of the right.")
I'm thinking some kind of logic in order to add new fields depending on what is chosen as 'type'. Can someone help me out? I searched the docs, but couldn't find anything that helped me.
Thanks!