Skip to content

Commit

Permalink
register url
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrumie committed Oct 30, 2021
1 parent f525142 commit dc18a04
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.urls import path

from api.views import RegisterUserView


urlpatterns = [
# Register
path('user/register/', RegisterUserView.as_view(), name="register-user"),


]
6 changes: 4 additions & 2 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

User = get_user_model()


class RegisterUserView(CreateAPIView):
queryset = User.objects.all()
serializer_class = RegisterUserSerializer

def create(self, request, *args, **kwargs):
response = super().create(request, *args, **kwargs)
token, created = Token.objects.get_or_create(user_id=response.data["id"])
token, created = Token.objects.get_or_create(
user_id=response.data["id"])
response.data['token'] = str(token)
return response
return Response(response, status=status.HTTP_201_CREATED)
3 changes: 2 additions & 1 deletion multipay/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
]

0 comments on commit dc18a04

Please sign in to comment.