Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RegisterForm(forms.ModelForm):
- Gebruikersnaam = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Gebruikersnaam'}), max_length=20, label="")
- Wachtwoord = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Wachtwoord'}), label="")
- Emailadres = forms.EmailField(required=False, widget=forms.TextInput(attrs={'placeholder': 'E-mailadres'}), label="")
- Profielfoto = forms.ImageField(required=False, label="")
- Biografie = forms.CharField(required=False, widget=forms.TextInput(attrs={'placeholder': 'Biografie'}), max_length=150, label="")
- class Meta:
- model = Profiel
- fields = ['Gebruikersnaam', 'Wachtwoord', 'Emailadres', 'Profielfoto', 'Biografie']
- class Profiel(models.Model):
- user = models.OneToOneField(User, primary_key=True)
- Profielfoto = models.ImageField()
- Biografie = models.CharField(max_length=150)
- def step3(request):
- if request.method == 'POST':
- form = RegisterForm(request.POST)
- if form.is_valid():
- Registratieform = form.save(commit=False)
- username = form.cleaned_data['Gebruikersnaam']
- password = form.cleaned_data['Wachtwoord']
- user = authenticate(username=username, password=password)
- Registratieform.user = request.user # Set the user object here
- Registratieform.save() # Now you can send it to DB
- if Registratieform.user is not None:
- if Registratieform.user.is_active:
- login(request, Registratieform.user)
- return redirect('/Dashboard/')
- return render_to_response("Home/index.html", {'form': form})
- else:
- form = RegisterForm()
- return render(request, 'Home/index.html', {'form': form})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement