class AccountCreateView(CreateView):
model = User #장고에서 기본제공하는 model
form_class = UserCreationForm
success_url = reverse_lazy('accountapp:hello_world')
template_name = 'accountapp/create.html'
accountapp->urls.py
urlpatterns = [
path('hello_world/', hello_world, name='hello_world'),
path('create/',AccountCreateView.as_view(),name='create')
]
class view는 .as_view()를 사용해서 view를 넘겨주어야함.
{% extends 'base.html'%}
{% block content %}
<div style="text-align: center">
<form action="{% url 'accountapp:create' %}" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" class="btn btn-primary">
</form>
</div>
{% endblock %}
