显示一条记录到页面
后台逻辑:
html页面:
两种判断方法:
可以根据前几个字符判断:
url配置技巧:
C:\Users\hlg\PycharmProjects\djangostart\djangostart\urls.py
报错:
TypeError at /form_go/ argument to reversed() must be a sequence Request Method: GET Request URL: http://127.0.0.1:8000/form_go/ Django Version: 1.9.8 Exception Type: TypeError Exception Value: argument to reversed() must be a sequence Exception Location: C:\Users\hlg\Envs\testvir2\lib\site-packages\django\core\urlresolvers.py in _populate, line 293 Python Executable: C:\Users\hlg\Envs\testvir2\Scripts\python.exe Python Version: 2.7.12 Python Path: ['C:\\Users\\hlg\\PycharmProjects\\djangostart', 'C:\\Users\\hlg\\PycharmProjects\\djangostart', 'C:\\Windows\\system32\\python27.zip', 'C:\\Users\\hlg\\Envs\\testvir2\\DLLs', 'C:\\Users\\hlg\\Envs\\testvir2\\lib', 'C:\\Users\\hlg\\Envs\\testvir2\\lib\\plat-win', 'C:\\Users\\hlg\\Envs\\testvir2\\lib\\lib-tk', 'C:\\Users\\hlg\\Envs\\testvir2\\Scripts', 'c:\\python27\\Lib', 'c:\\python27\\DLLs', 'c:\\python27\\Lib\\lib-tk', 'C:\\Users\\hlg\\Envs\\testvir2', 'C:\\Users\\hlg\\Envs\\testvir2\\lib\\site-packages'] Server time: Thu, 24 May 2018 15:44:37 +0800 Error during template rendering In template C:\Users\hlg\PycharmProjects\djangostart\templates\message_form.html, error at line 101 argument to reversed() must be a sequence 91 margin-top: 10px; 92 } 93 .success-msg{ 94 color: #80A24A; 95 margin-top: 10px; 96 margin-bottom: 10px; 97 } 98 </style> 99 </head> 100 <body> 101 <form action="{% url 'go_form' %}" method="post" class="smart-green"> 102 <h1>留言信息 103 <span>请留下你的信息.</span> 104 </h1> 105 <label> 106 <span>姓名 :</span> 107 <input id="name" type="text" value="{% ifequal my_message.name|slice:'1' '东' %}东方有明珠2{% endifequal %}" name="name" class="error" placeholder="请输入您的姓名"/> 108 <div class="error-msg"></div> 109 </label> 110 111 <label>
解决办法: