Python

Python

Made by DeepSource

Nullable ManyToManyField found PTC-W0905

Bug risk
Major
Autofix

Having a nullable many-to-many field doesn't do anything. The declaration of a ManyToManyField causes the creation of an intermediate table to hold the relationship. Each relation between the two tables is an entry in this new table. By definition, having no relations between two tables would mean no entries in this table. There's no use of null.

Consider removing null=True from this property.

Not Preferred:

class User(models.Model):
    chat_id = models.ManyToManyField(null=True)

Preffered:

class User(models.Model):
    chat_id = models.ManyToManyField()