【问题标题】:How to display multiple database values in a single input?如何在单个输入中显示多个数据库值?
【发布时间】:2023-01-20 16:24:28
【问题描述】:

我有几个小时的小问题。 我正在开发一个使用 django python 的应用程序。 (我是 Django 的新手)

我目前在前端工作,我想在输入中显示名字和姓氏。这适用于两个单独的输入,但我想在同一输入中显示名字和姓氏。

我不知道该怎么做

<input style="background-color: blue;"{{form.user_first_name}}>

谢谢

【问题讨论】:

  • 我假设这两个名字是字符串?你不能只是连接字符串并将新字符串输出到输入中吗?

标签: python html django


【解决方案1】:

尝试这个

<input style="background-color:blue;" value="{{form.user_first_name.value}} {{form.user_last_name.value}}">

请参阅以下链接

https://docs.djangoproject.com/en/4.1/topics/forms/#looping-over-the-form-s-fields https://docs.djangoproject.com/en/4.1/topics/forms/

【讨论】:

    猜你喜欢
    • 2021-09-30
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多