Hi, so I’m in the process for attempting to create new users with information entered into a form. When the call to create a new user is executed I get a POST / account/register 200 response from the server. It seems to have worked…
I have a register function set to redirect to the homepage and it doesn’t work
Lastly, when I login to the admin console nothing is registered.
Im stuck and I’m new, I tried to debug with in VS code and it seems to get stuck in the crispy forms logic and I’m unsure the of the next way to approach this.
from django.urls import path
from . import views
urlpatterns = [
path('register', views.register, name='register'),
]
from django.shortcuts import redirect, render
from .forms import CreateUserForm
def register(request):
form = CreateUserForm()
if request.method == 'POST':
form = CreateUserForm(request.POST)
if form.is_valid():
form.save()
return redirect('store')
context = {'form':form}
return render(request, 'account/registration/register.html', context=context)
{% include "store/base.html" %}
{% load static %}
{% load crispy_forms_tags %}
{% block content %}
<!-- <style>
body{
background-color: gray;
}
</style> -->
<body>
<br>
<div class="container bg-blue shadow-md p-5 form-layout">
<h3> Create your account </h3>
<h5> Purchase Items </h5>
<br>
<form method="POST" autocompelte="off">
{% csrf_token %}
{{form.username|as_crispy_field}}
<br>
{{form.email|as_crispy_field}}
<br>
{{form.password1|as_crispy_field}}
<br>
{{form.password2|as_crispy_field}}
<br> <br>
<button type="submit" class="btn btn-secondary btn-lg w-100 btn-block p-2"> Create Account </button>
</form>
</div>
</body>
{% endblock %}