hyeonga_code

파이선 웹구축_장고_17_계정 프로필 페이지 본문

Python_Django

파이선 웹구축_장고_17_계정 프로필 페이지

hyeonga 2023. 6. 9. 05:59
반응형

 

- 계정 프로필 페이지

1. 로그인 시, 프로필 확인 버튼 생성 <templates> > <adm> > 'index.html'

'index.html'

=====

1
2
3
4
5
6
7
8
<h1><b>MAIN PAGE</b></h1>
<br><br>
 
{% if request.user.is_authenticated %}
     <a href="{% url 'profile' %}"><button>Profile</button></a>
{% else %}
 
{% endif %}
cs

 

 

 

2. 경로 설정 <adm> > 'urls.py'

'urls.py'

=====

1
2
3
4
5
6
from django.urls import path, include
from . import views
 
urlpatterns = [
    path('profile/', views.profile, name='profile'),
]
cs

 

 

 

 

3. 함수 설정 <adm> > 'views.py'

'views.py'

=====

1
2
3
4
5
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
 
def profile(request):
    return render(request, 'adm/profile.html')
cs

 

 

 

 

4. 프로필 페이지 작성 <templates> > <adm> > 'profile.html'

'profile.html'

=====

1
2
3
4
5
6
7
8
<h1><b>PROFILE PAGE</b></h1>
<br><br>
 
<input type='text' disabled value="{{user}}"><br><br>
<input type='text' disabled value="{{user.email}}"><br><br>
<input type='text' disabled value="{{user.first_name}}"><br><br>
<input type='text' disabled value="{{user.last_name}}"><br><br>
<a href="{% url 'index' %}"><button type='button'>Main</button></a>
cs

 

반응형