Very basic profile view
This commit is contained in:
parent
ea9d38fece
commit
27075d101f
|
|
@ -100,6 +100,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
LOGOUT_REDIRECT_URL = '/'
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
||||
|
|
|
|||
|
|
@ -20,5 +20,6 @@ from . import views
|
|||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('accounts/new-user/', views.new_user, name='new-user'),
|
||||
path('accounts/profile/', views.profile, name='profile'),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from .forms import SignupForm
|
|||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
def new_user(request):
|
||||
if request.method == 'POST':
|
||||
|
|
@ -14,3 +15,7 @@ def new_user(request):
|
|||
form = SignupForm()
|
||||
|
||||
return render(request, 'registration/new-user.html', {'form': form})
|
||||
|
||||
@login_required
|
||||
def profile(request):
|
||||
return render(request, 'registration/profile.html')
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
<nav>
|
||||
<ul>
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="#">Account</a></li>
|
||||
<li><a href="{% url 'profile' %}">Profile</a></li>
|
||||
<li><a href="{% url 'logout' %}">Logout</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% url 'login' %}">Login</a></li>
|
||||
<li><a href="{% url 'new-user' %}">Create account</a></li>
|
||||
|
|
|
|||
19
templates/registration/profile.html
Normal file
19
templates/registration/profile.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{% extends "base_main.html" %}
|
||||
{% block title %}Profile {{ user.username }}{% endblock %}
|
||||
{% block main %}
|
||||
<h1>Profile {{ user.username }}</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Username</td>
|
||||
<td>{{ user.username }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>First name</td>
|
||||
<td>{{ user.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last name</td>
|
||||
<td>{{ user.last_name }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endblock %}
|
||||
Loading…
Reference in a new issue