[Fixed]-Django model designing

1👍

Here’s how I’d do it along with some other code style changes that are standard for python and Django.

# Your models name should be singular rather than plural.
class Sport(models.Model):
        # Use name here rather than sports since it's more descriptive.
        name = models.CharField(max_length=100)

class Student(models.Model):
        # You're in the student model, it can be assumed that the name is the student's name.
        name = models.CharField(max_length=255)
        # The fields should be lower case.
        room_no = models.IntegerField()
        sports = models.ManyToManyField(Sport)

Leave a comment