-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e90b26
commit 881b514
Showing
11 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class UsersConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'users' |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.urls import path | ||
|
||
from .views import SignUpView, CustomLoginView | ||
|
||
app_name = 'user' | ||
|
||
urlpatterns = [ | ||
path('signup/', SignUpView.as_view(), name='signup'), | ||
path('login/', CustomLoginView.as_view(), name='login'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib import auth | ||
from django.views.generic import CreateView | ||
|
||
from django.contrib.auth import views, authenticate, login | ||
|
||
from django.contrib.auth.forms import UserCreationForm | ||
|
||
from django.urls import reverse_lazy | ||
|
||
class SignUpView(CreateView): | ||
|
||
template_name = 'users/signup.html' | ||
|
||
form = UserCreationForm | ||
|
||
success_url = reverse_lazy('photo:list') | ||
|
||
def form_valid(self, form): | ||
|
||
user = authenticate( | ||
username=form.cleaned_data["username"], | ||
password=form.cleaned_data["password1"], | ||
) | ||
|
||
login(self.request, user) | ||
|
||
return super().form_valid(form) | ||
|
||
class CustomLoginView(views.LoginView): | ||
|
||
template_name = 'users/login.html' |