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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -