Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- class userProfile(models.Model):
- usermail = models.CharField(max_length=264)
- username = models.CharField(max_length=264)
- userpass = models.CharField(max_length=264)
- class companyProfile(models.Model):
- companymail = models.CharField(max_length=264)
- companyname = models.CharField(max_length=264)
- companypass = models.CharField(max_length=264)
- from django import forms
- from Pruebas_app.models import companyProfile, userProfile
- class registerCompany(forms.Form):
- companypassconf = forms.CharField()
- class Meta():
- model = companyProfile
- fields = ['companymail','companyname', 'companypass']
- labels = {'companymail': '', 'companyname': '', }
- widgets = { 'companypass': forms.PasswordInput(),}
- class registerUser(forms.Form):
- userpassconf = forms.CharField()
- class Meta():
- model = companyProfile
- fields = ['usermail','username', 'userpass']
- labels = {'usermail': '', 'username': '', }
- widgets = {'userpass': forms.PasswordInput(),}
- <form action="{ url 'user_register'}" method="post">
- <input type="text" name="username">
- <input type="email" name="usermail">
- <input type="password" name="userpass">
- <input type="password" name="userpassconf">
- <input type="submit" value="Register">
- </form>
- <form action="{ url 'company_register'}" method="post">
- <input type="text" name="companyname">
- <input type="email" name="companymail">
- <input type="password" name="companypass">
- <input type="password" name="companypassconf">
- <input type="submit" value="Register">
- </form>
- from django.shortcuts import render
- from Pruebas import forms
- from Pruebas.forms import registerCompany, registerUser
- from django.http import HttpResponse
- def user_register(request):
- form = forms.registerUser()
- regd = False
- passmatch = True
- if request.method == "POST":
- form = registerUser(request.POST)
- if form.is_valid():
- form_data = form.cleaned_data
- print (form_data.get("userpass"))
- if form_data.get("userpass") == form_data.get("userpassconf"):
- passmatch = True
- form.save()
- regd = True
- print("saved")
- else:
- passmatch = False
- else:
- print("error")
- red = 'Pruebas/register.html'
- regd = False
- return render(request, 'Pruebas/register.html', {'registered': regd, "matchPass": passmatch})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement