在request.POST Django

时间:2017-07-16 17:00:22

标签: html django httprequest wagtail

我试图获取点击的li元素的id,但我没有得到它 我需要一些帮助,并提前感谢

编辑:我使用wagtail cms并且我的应用程序基于 models.py:

class index(Page)
    def get_context(self, request):
     base_tags = ["foo","boo","voo"]
        if request.method == "POST" :
            tag = request.POST[("id","")]
            blogpages = BlogPage.objects.live().filter(tags__name__in=[tag])
        return #....

的index.html:

<form id="content" method="post">
<ul class="nav nav-tabs" role="tablist">
    {% csrf_token %}
    {%for tag in base_tags %}
  <li   name="id" value="{{tag.id}}" onclick="content.submit();"  role="presentation"><a href="#{{tag}}" aria-controls="{{tag}}" role="tab" data-toggle="tab">{{tag}}</a></li>
  {% endfor %}
</ul>
</form>

1 个答案:

答案 0 :(得分:0)

根本不要在这里使用表格。使用标准链接:

for

并定义您的网址和视图,如下所示:

levels(df$country)[levels(df$country) %in% i] <- "Europe"

...

<ul class="nav nav-tabs" role="tablist">
  {% for tag in base_tags %}
     <li aria-controls="{{tag}}" role="tab" data-toggle="tab"><a href="{% url "tags" tag %}">{{tag}}</a></li>
  {% endfor %}
</ul>