LoginSignup
2
1

More than 1 year has passed since last update.

[Django] (fields.W340) null has no effect on ManyToManyField.

Posted at

Warning

model name:  (fields.W340) null has no effect on ManyToManyField.

null has no effect since there is no way to require a relationship at the database level.

ManyToManyの実態は、リレーションテーブルなので、そのレコードの中でnullを許容するということが物理的にできないです。
image.png
https://stackoverflow.com/questions/49677910/filter-data-from-two-tables-having-many-to-many-relation-django

解決策


field_name = models.ManyToManyField(ModelName, blank=True, null=True, related_name='n')

field_name = models.ManyToManyField(ModelName, blank=True, related_name='n')
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1