LoginSignup
0
0

More than 3 years have passed since last update.

Djangoのget_object_or_404()とModel.objects.filter()の違い

Last updated at Posted at 2020-11-20

get_object_or_404()は一つだけ。idかonetoonefieldsに便利。

chat = get_object_or_404(Chat, id=id)

Model.objects.filter()は複数ゲット

chat = Chat.objects.filter(user='papa')
0
0
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
0
0