-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jamestaggart28/jamestaggart28
Authentication Navigation
- Loading branch information
Showing
7 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
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
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,5 @@ | ||
{% extends 'base.html' %} | ||
{% block title %} profile{% endblock title %} | ||
{% block content %} | ||
<p>{{ user.username }}</p> | ||
{% endblock content %} |
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
File renamed without changes.
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,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}register{% endblock title %} | ||
|
||
{% block content %} | ||
<form method="post"> | ||
{% csrf_token %} | ||
{{ form.as_p }} | ||
<input type="submit" value="submit" /> | ||
</form> | ||
{% endblock content %} |
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
from django.urls import path | ||
from core.views import Home | ||
from core.views import Home, Register, Profile | ||
from django.conf.urls import include | ||
|
||
app_name = "core" | ||
|
||
account_patterns = [ | ||
path('registration/', Register.as_view(), name="register"), | ||
path('profile/', Profile.as_view(), name="profile") | ||
] | ||
|
||
urlpatterns = [ | ||
path('', Home.as_view(), name="home") | ||
path('accounts/', include(account_patterns)), | ||
path('', Home.as_view(), name="home"), | ||
] |
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 |
---|---|---|
@@ -1,6 +1,27 @@ | ||
from django.views.generic import TemplateView | ||
from django.contrib.auth import login, authenticate | ||
from django.contrib.auth.forms import UserCreationForm | ||
from django.views.generic.edit import FormView | ||
from django.shortcuts import redirect | ||
|
||
|
||
# Create your views here. | ||
class Home(TemplateView): | ||
template_name = "core/home.html" | ||
|
||
|
||
class Register(FormView): | ||
form_class = UserCreationForm | ||
template_name = 'registration/register.html' | ||
|
||
def form_valid(self, form): | ||
form.save() | ||
username = form.cleaned_data.get('username') | ||
raw_password = form.cleaned_data.get('password1') | ||
user = authenticate(username=username, password=raw_password) | ||
login(self.request, user) | ||
return redirect('core:home') | ||
|
||
|
||
class Profile(TemplateView): | ||
template_name = "core/profile.html" |