我创建了一个表单和POST选项,其中包含一个动作以转到特定的URL。虽然,一旦定向模板不更新。
我需要再次点击Enter然后显然我的请求丢失了所以我得到了异常值get_context_data() takes exactly 2 arguments (1 given)
任何想法为什么?
以下是问题的代码和打印屏幕。
网址
url(r'^all_rooms/$', views.AllRoomsView.as_view(), name='roomsdetails'),
模板
<form action="/blocks/all_rooms/" method="post" >
{% csrf_token %}
<ul>
{% for choice in form.my_choice_field.field.choices %}
<li>
<input type="radio" name="my_choice_field" value="{{choice.0}}"
{% ifequal form.my_choice_field.data choice.0 %}
checked="checked"
{% endifequal %}/>
<label for="">{{choice.1}}</label>
</li>
{% endfor %}
</ul>
<input type="submit" value="Submit" />
</form>
编辑:
下面是我的AllRoomsView类。我怀疑这是问题所在的类。
class AllRoomsView(ListView):
template_name = 'prostats/roomsdetail.html'
queryset = Room.objects.all()
def get_context_data(self, request, **kwargs):
context = super(AllRoomsView, self).get_context_data(**kwargs)
context['rooms'] = Room.objects.all()
context['rlog'] = RoomLog.objects.all()
roomsdates = []
for r in context['rlog']:
if r not in roomsdates:
roomsdates.append(r.update_date)
roomextracted = []
for i in roomsdates:
if i not in roomextracted:
roomextracted.append(i)
context['roomextracted'] = roomextracted
choosend = '2016-02-16'
context['roomfiltersettime'] = RoomLog.objects.filter(update_date__lte = choosend)
return context