作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Django 站点中有一个表单
<form method="POST" action="." class="right_custom">{% csrf_token %}
<br>{% trans "Enter the discount coupon code if you have any" %}</br>
<input type="text" name="coupon_code" size="25" maxlength="25" />
<input type="submit" name="submit" value="Caluclate Discount"/>
</form>
Caluclate Discount
.我怎样才能做到这一点?如果我使用
{% trans %}
标签, View 将如何捕获正确的发布请求?
if postdata['submit']=="Caluclate Discount"
以确定它是哪个提交请求。
最佳答案
我能够让翻译工作。
感谢@linux-warrior 和@Joachim 的回答
现在的形式是
<form method="POST" action="." class="right_custom">{% csrf_token %}
<input type="hidden" name="form_name" value="discount_form" />
<br>{% trans "Enter the discount coupon code if you have any" %}</br>
<input type="text" name="coupon_code" size="25" maxlength="25" />
<input type="submit" name="submit" value="{% trans "Caluclate Discount" %}" />
</form>
postdata['form_name']=='discount_form'
在我看来
关于django - 如何在 Django 中翻译表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8500862/
我是一名优秀的程序员,十分优秀!