from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm

class RegistrationForm(UserCreationForm):
email=forms.EmailField(required=True)

class Meta:
model=User
fields ={
'username',
'first_name',
'last_name',
'password1',
'email',
}
def save(self,commit=True):
user = super(RegistrationForm,self).save(commit=False)
user.fisrt_name=self.cleaned_data['first_name']
user.last_name=self.cleaned_data['last_name']
user.emil=self.email.cleaned_data['email']

if commit:
user.save()
return user
*This is my form.py file*


from django.shortcuts import render,redirect
from app.forms import RegistrationForm
from django.contrib.auth.forms import UserCreationForm
from django.http import HttpResponse
from django.views.generic import TemplateView
from django.template import loader

def register(request):
if request.method =='POST':
form=RegistrationForm(request.POST)
if form.is_valid():
form.save()
return redirect('home')
else:
form=RegistrationForm()

args={'form':form}
return render(request,'reg_form.html',args)
*And this is my view.py file*


*when I'm pressing the submit button it will show me "view 
app.views.register didn't return an HttpResponse object. It returned None 
instead"*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11548a24-127a-46cf-866e-66cd96e6f178%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to