如何在单个输入中显示多个数据库值?



我有几个小时的小问题。我正在研究一个使用django python的应用程序。(I'm new to Django)

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

我不知道该怎么做

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

感谢

try this

<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-fieldshttps://docs.djangoproject.com/en/4.1/topics/forms/

最新更新