Hello everyone

I have a problem, with my code please, I doing crud useradmin django rest 
framework.

this is my urls.py 

urlpatterns = [
    url(r'^$', views.ProfileList.as_view()),
    url(r'^users/$', views.UserList.as_view()),
    url(r'^users/(?P<pk>[0-9]+)/$', views.UserDetail.as_view()),
    url(r'^users/update/(?P<pk>[0-9]+)/$', views.UserUpdate.as_view()),
]


users/$ and users/(?<pk>[0-9]+)/$ working well, but the last url not woking

my code views.py 

class UserUpdate(generics.UpdateAPIView):
    serializer_class = UserUpdateSerializer
    queryset = User.objects.all()
    serializer_class = UserUpdateSerializer
    permission_classes = (permissions.IsAuthenticated,)

    def update(self, request, *args, **kwargs):
        instance = self.get_object()
        instance.name = request.data.get("username")
        instance.save()

        serializer = self.get_serializer(instance)
        serializer.is_valid(raise_exception=True)
        self.perform_update(serializer)

        return JsonResponse(serializer.data)


my file serializers.py 

class UserUpdateSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = user_fields



and the error show me this 

Page not found (404)
Request Method: PUT
Request URL: http://127.0.0.1:8000/api/v1/users/update/2

Using the URLconf defined in colonybitbasics.urls, Django tried these URL 
patterns, in this order:

   1. ^admin/
   2. ^api/v1/auth/
   3. ^api/v1/refresh/
   4. ^api/v1/verify/
   5. ^api/v1/ ^$
   6. ^api/v1/ ^users/$
   7. ^api/v1/ ^users/(?P<pk>[0-9]+)/$
   8. ^api/v1/ ^users/update/(?P<pk>[0-9]+)/$

The current path, api/v1/users/update/2, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.

and I don't understand why

I am new in django please helpe me.


regards
Angel






















































































 




-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to