Skip to content

Commit

Permalink
user on boarding
Browse files Browse the repository at this point in the history
  • Loading branch information
ZEZE1020 committed Jan 13, 2025
1 parent 03cb5ff commit 73a4985
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from django.shortcuts import render, get_object_or_404
from .models import CustomUser, Follow, Post
from .forms import CustomUserCreationForm, CustomUserChangeForm
from django.shortcuts import render

def home(request):
return render(request, 'home.html')

class UserViewSet(viewsets.ModelViewSet):
queryset = CustomUser.objects.all()
serializer_class = UserSerializer
Expand Down Expand Up @@ -62,6 +67,24 @@ def user_profile(request, user_id):
return render(request, 'accounts/profile.html', context)


def login_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
if form.is_valid():
user = form.get_user()
login(request, user)
return redirect('home')
else:
form = AuthenticationForm()
return render(request, 'login.html', {'form': form})


def logout_view(request):
if request.method == 'POST':
logout(request)
return redirect('home')


def signup(request):
if request.method == 'POST':
form = CustomUserCreationForm(request.POST, request.FILES)
Expand Down
Binary file modified social_media_api/__pycache__/settings.cpython-313.pyc
Binary file not shown.

0 comments on commit 73a4985

Please sign in to comment.