*_set attributes on Django Models

后端 未结 4 1557
梦毁少年i
梦毁少年i 2021-02-04 03:09

I have a very basic question about django.db.models.

In this official django tutorial, if you search for word \"choice_set\", you will see tha

4条回答
  •  Happy的楠姐
    2021-02-04 03:58

    Choice has a ForeignKey to Poll, and Django auto-generates the convenience method Poll.choice_set() to access all the choices that refer to that poll.

    There's a great article covering the topic of following relations backwards in the Django docs:

    https://docs.djangoproject.com/en/1.11/topics/db/queries/#following-relationships-backward

提交回复
热议问题