I'm writing an enrollment website for my school, and using Django for the framework. For the registration, I require a username, password, and registration token. Those have yet to be validated, all I'm attempting to do right now is go from the registration input page (which uses a POST request) to a "You have successfully registered" page. Somewhere along the line, the csrf token is apparently refusing to be validated.
My view:
def register(request):
return render(request, 'enroller/successfulEnroll.html')
My page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="{% url 'register' %}" method="post"> {% csrf_token %}
<div class="container">
<label><b>New Username</b></label>
<input type="text" placeholder="Username" name="uname" required>
<br>
<label><b>Password</b></label>
<input type="password" placeholder="Password" name="psw" required>
<br>
<label><b>Registration Password</b></label>
<input type="text" placeholder="Registration Key" name="reg" required>
<br>
<input type="submit" value="Register" />
</div>
</form>
</body>
</html>
When I attempt to go from the registration page to the success page, it gives me an error 403 (CSRF Verification failed. Request aborted). However, when I attempt to go to the url mysite.com/register/, it returns the page I requested with no error.
Is there any way to fix this? I've been looking at RequestContext, but I'm not entirely sure where it would be used.