我想创建内联表单的表单,但我收到错误
vehicle_group_add()只需要2个参数(给定1个)
views.py
def vehicle_group_add(request, pk):
group = Vehicle_group.object.get(pk=pk)
if request.method == "POST":
form = VehicleInlineFormset(request.POST, request.FILES, instance=group)
if form.is_valid():
post = form.save(commit=False)
post.save()
return redirect('vehicle_group_add.html', pk=post.pk)
else:
form = VehicleInlineFormset(instance=group)
return render(request,'vehicle_group_add.html', {'form': form}, context_instance= RequestContext(request))
forms.py
class VehicleGroup(forms.ModelForm):
class Meta:
model = Vehicle_group
fields = ['name_group','description','manufacture','manufacture_type']
class VehicleAttribute(forms.ModelForm):
class Meta:
model = Vehicle_attribute
fields = ['operation','payload_meter','payload_limit_low','payload_limit_high']
VehicleInlineFormset = inlineformset_factory(Vehicle_group, Vehicle_attribute, fields=('operation',))
我正在使用django versi 1.8.2
你可以帮我解决这个问题吗?答案 0 :(得分:2)
您的网址似乎错误
在urls.py中,您的网址应该是这样的。
resolve()
你必须像这样打电话给这个网址 让我知道任何其他错误
result