1

I have a Event model with two fields category and sub_category . Both of them are choice fields

here are choices :

Category_Choices (
     ('1','a')
     ('2','b')
   )


A_SubCategory_Choices(
    ('1','x')
     ('2','y')
 )

B_SubCategory_Choices(
    ('1','m')
     ('2','n')
 )

and here is my Event Model

class Events(models.Model):
     category = models.CharField(max_length=100, choices=Category_Choices,)
     sub_category = models.CharField(max_length=100, )

How I can set a choice field for my sub_category that in django admin if I select category a it shows me category A choice fields and if I select category b it shows me category B choices fields

Ankit Jaiswal
  • 22,859
  • 5
  • 41
  • 64
Nima
  • 490
  • 2
  • 10
  • 19

0 Answers0