DEV Community

Ashutosh Mishra
Ashutosh Mishra

Posted on

Choice for each item in field in models

Choice for each item in field in models

0

If i have 5 diffent sport in Sports then in Intrest model i want to put level to each of those 5 sports seprately,and want to print.How to do it.

exampl:cricket=Advance

Football=Beginner like this

            class Sports(models.Model):
                Sport=models.CharField(max_length=30)

            class User(models.Model):
                user=models.CharField(max_length=30)

            class Intrest(models.Model):
                user_name=models.Foreignkey(User,on_delete=models.CASCADE)
                sport=models.Foreignkey(Sports,on_delete=models.CASCADE)
                LEVEL=(
                    ('1','Beginer'),
                    ('2','Intermediate'),
                    ('3','Advance'),
                    ('4','Nevel Played'),

Top comments (0)