최신글
hyeonga_code
파이선 웹구축_장고_20_계정 프로필 수정 본문
반응형
- 계정 프로필 수정
1. 프로필 페이지에 수정 버튼 생성 <templates> > <adm> > 'profile.html'
'profile.html'
=====
1
2
3
4
5
|
<h1><b>PROFILE PAGE</b></h1>
<br><br>
<a href="{% url 'update' %}"><button type='button'>Update</button></a>
|
cs |
2. 경로 설정 <adm> > 'urls.py'
'urls.py'
=====
1
2
3
4
5
6
|
from django.urls import path, include
from . import views
urlpatterns = [
path('update/', views.update, name='update'),
]
|
cs |
3. 함수 생성 <adm> > 'views.py'
'views.py'
=====
1
2
3
4
5
6
|
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from .models import User
def update(request):
return render(request, "adm/update.html")
|
cs |
4. 업데이트 페이지 작성 <templates> > <adm> > 'update.html'
'update.html'
=====
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<h1><b>UPDATE PAGE</b></h1>
<br><br>
<form method="post">
{% csrf_token %}
<input type='text' disabled value="{{user}}"><br><br>
#_ 아이디 변경 불가
<input type='text' name='umail' value="{{user.email}}"><br><br>
<input type='text' name='fname' value="{{user.first_name}}"><br><br>
<input type='text' name='lname' value="{{user.last_name}}"><br><br>
<button>Update</button>
<a href="{% url 'profile' %}"><button type='button'>Cancle</button></a>
</form>
|
cs |
반응형
'Python_Django' 카테고리의 다른 글
파이선 웹구축_장고_22_댓글_상속 테이블 (0) | 2023.06.14 |
---|---|
파이선 웹구축_장고_21_계정 비밀번호 변경 (0) | 2023.06.13 |
파이선 웹구축_장고_19_계정 회원가입 페이지 (0) | 2023.06.11 |
파이썬 웹구축_장고_18_계정 삭제 (0) | 2023.06.10 |
파이선 웹구축_장고_17_계정 프로필 페이지 (0) | 2023.06.09 |