26강 DeleteView기반 회원탈퇴 구현

짜부·2023년 1월 20일

작정하고 장고

목록 보기
33/41
  1. DeleteView만들기
class AccountDeleteView(DeleteView):
    model = User
    success_url = reverse_lazy('accountapp:hello_world')
    template_name = 'accountapp/delete.html'
  1. url만들기
    urls.py
path('delete/<int:pk>', AccountDeleteView.as_view(),name='delete'),
  1. delete.html만들기
{% 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>Quit</h4>
        </div>
        <form action="{% url 'accountapp:delete' pk=user.pk %}" method="post">
            {% csrf_token %}
            <input type="submit" class="btn btn-danger rounded-pill col-6 mt-3">
        </form>
    </div>
{% endblock %}

*번외 header에 create접송할 수 있게 만들기, 빼먹음
header.html

			<a href="{% url 'accountapp:create' %}">
                <span>Create</span>
            </a>
profile
화이팅

0개의 댓글