User0511
User0511

Reputation: 725

Django error takes exactly 2 arguments (1 given)

i want to create form with inline form but i am getting error

vehicle_group_add() takes exactly 2 arguments (1 given)

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',))

i am using django versi 1.8.2

can you help me solve this problem?

Upvotes: 0

Views: 2482

Answers (1)

jatinkumar patel
jatinkumar patel

Reputation: 2990

It seems that you have wrong structure of url

In urls.py, your url should be like this.

url(r'^xxx/(?P<pk>.*)/$', vehicle_group_add),

and you have to callthis url like this Let me know any other error

 /xxx/123/

Upvotes: 2

Related Questions