Django "get() got an unexpected keyword argument 'pk'" error -
i trying redirect page intend implement object's homepage after creation of one.
below corresponding part of views.py
new_station_object.save() return httpresponseredirect(reverse("home_station", kwargs={'pk': new_station_object.id} )) class stationhome(view): def get(self, request): return httpresponse("created :)")
and corresponding part of urls.py;
url(r'^station/(?p<pk>\d+)$', stationhome.as_view(), name='home_station'),
but said error;
typeerror @ /station/2 get() got unexpected keyword argument 'pk'
someone please me out.
the function getting 1 argument more supposed to. change to:
def get(self, request, pk):
the value of pk equal pattern has been matched, , since you've specified it's going number, type of pk int.
Comments
Post a Comment