Working on the Corey Schafer django tutorials, and I’ve built a registration page that is supposed to redirect back to the home page (newsfeed) and display a confirmation message. However I don’t know whether the issue is just in the redirection or where it is.
def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
username = form.cleaned_data.get('username')
messages.success(request, f'Account created for {username}!')
return redirect('')
else:
form = UserCreationForm()
return render(request, 'users/register.html', {'form': form})
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% extends "newsfeed/base.html" %}
{% block content %}
<div class="content-section">
<form method="POST">
{% csrf_token %}
<fieldset>
<legend class="border-bottom mb-4">Join Today</legend>
{{ form.as_p }}
</fieldset>
<div class="form-group">
<buttom class="btn btn-outline-info" type="submit">Sign Up</buttom>
</div>
</form>
<div class="border-top pt=3">
<small class="text-muted">
Already have an account? <a class="ml-2" href="#">Sign In</a>
</small>
</div>
</div>
{% endblock content %}
I think that those are all of the relevant code snippets
I’ve checked all of my paths and I believe that they are correct. My real issue is figuring out where the issue is as there is no syntax error.
Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.