class AccountUpdateView(UpdateView):
model = User #장고에서 기본제공하는 model
form_class = AccountUpdateForm
success_url = reverse_lazy('accountapp:hello_world')
template_name = 'accountapp/update.html'
path('update/<int:pk>', AccountUpdateView.as_view(),name='update'),
{% extends 'base.html'%}
{% load bootstrap4 %}
{% block content %}
<div style="text-align: center;max-width:500px; margin: 4rem auto">
<div class="mb-4"> {# margin bottom #}
<h4>Change Info</h4>
</div>
<form action="{% url 'accountapp:update' pk=user.pk%}" method="post">
{% csrf_token %}
{% bootstrap_form form %}
<input type="submit" class="btn btn-dark rounded-pill col-6 mt-3">
</form>
</div>
{% endblock %}
{% if target_user == user %}
<a href="{% url 'accountapp:update' pk=user.pk %}">
<p>
Change Info
</p>
</a>
{% endif %}
target_user와 지금 접속한 유저가 같다면 update링크 보이게 하기

from django.contrib.auth.forms import UserCreationForm
class AccountUpdateForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].disabled = True
자세한 내용은 나중에 시간될 때 다룰 예정
