英文:
On python function the dictionary is not return the full value of the key?
问题
以下是您提供的代码的翻译部分:
App view code:
def home(request):
    text1 = "示例名称"
    temp_dict = {'txt1': text1, 'txt2': '您的姓名'}
    return render(request, 'Second2_app/index.html', context=temp_dict)
index html code:
<div>
    <label for="name">用户名</label>
    <input
        id="name"
        type="text"
        placeholder={{txt1}}
        name="name"
        required
    />
</div>
项目文件中我定义的URL:
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('Second_app.urls')),
    path('Customers/', include('Second_app.urls')),
]
这些是您代码中的部分内容的中文翻译。如果您有任何其他需要,请随时提问。
英文:
App view code:
def home(request):
    # return HttpResponse("<h1> This is Home Page </h1>")
    text1 = "Example Name"
    temp_dict = {'txt1': text1, 'txt2': 'Your Name'}
    return render(request, 'Second2_app/index.html', context=temp_dict)
index html code:
<div>
        <label for="name">User name</label>
        <input
               id="name"
               type="text"
               placeholder={{txt1}}
               name="name"
               required
               />
      </div>
url I define on project file
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('Second_app.urls')),
    path('Customers/', include('Second_app.urls')),
]
I am expecting why my desire output is not shown in the html file.......
答案1
得分: 1
我的问题解决了,这是我的愚蠢错误。
<div>
 <label for="name">用户名</label>
 <input id="name" type="text" placeholder="{{txt1}}" name="name" required />
</div>
英文:
Got my solution it was a silly mistake from me.
<div>
 <label for="name">User name</label>
 <input id="name" type="text" placeholder="{{txt1}}" name="name" required />
</div>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论