django form dropdown list of stored models

前端 未结 2 1074
暗喜
暗喜 2021-02-01 07:04

I am trying to create a form for a library where a user can perform 2 actions: add a new book or open the stored information of an existing one. Books have 2 fields (title and a

2条回答
  •  隐瞒了意图╮
    2021-02-01 07:29

    Supplement to J. Ghyllebert's answer to address rendering question in comments. Template rendering:

    {% csrf_token %} {{ form.as_p }}

    Or single field:

    {% csrf_token %}
    {{ form.days }}

    Documentation: https://docs.djangoproject.com/en/3.1/topics/forms/#the-template

提交回复
热议问题