Even if I register as a member, I can't check it on the administration page, so I can't save it in the database, but I don't know where it went wrong.
Register.html code.
<html>
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link href="https://fonts.googleapis.com/css?family=Dosis&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<title>Regitser With PAM</title>
</head>
<body>
<h1>Register With PAM</h1>
{% {% if registered %}
<strong>Thank you for registering!</strong>
<a href = "/mysite">Return to MainPage.</a><br />
{% {% else %}
<strong>Register here!</strong><br />
<form id = "user_form" method = "post" action = "/mysite/register/" enctype = "multipar/form-date">
{% {% csrf_token %}
{{ {{ user_form.as_p }}
{{ {{ profile_form.as_p}}
<input type = "submit" name "submit" value = "Register" />
</form>
{% {% endif %}
</body>
</html>
models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
schoolid = models.PositiveIntegerField(primary_key=True, validators=[MaxValueValidator(5)])
phone_number = models.PositiveIntegerField(primary_key=True, validators=[MaxValueValidator(11)])
def __str__(self):
return self.user,username
views.py
def register(request):
context = RequestContext(request)
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = UserProfile(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
registered = True
else:
print(user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = UserProfileForm()
return render_to_response(
'mysite/register.html',
{'user_form':user_form, 'profile_form':profile_form, 'registered': registered}, context)
Execution screen
However, even if you press register and register, if you go to the admin page...
If you register there, it will come up with 404 error
If you look at the subscription page, the address is /register, but the action is
in HTML/mysite/register/ Yes
Just change it to "/register" or ""
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.