Views.py
#For Cystomer Registration
class CustomerRegistrationView(View):
def get(self,request):
form = CustomerRegistrationForm()
return render(request,'mp/register.html',{'form':form})
def post(self,request):
form = CustomerRegistrationForm(request.POST)
if form.is_valid():
messages.success(request,'Congratulations Registerd Succesfuly ')
form.save()
success_url = reverse_lazy('profile')
return render(request,'mp/register.html',{'form':form})
#For Creating Profile
class ProfileCreate(LoginRequiredMixin,CreateView):#ye hogia hamara upload wala
model = Profile
fields = ['user_name','user_ethnicity','SelectGender','user_job','user_age','mother_additionalinfo']
success_url = reverse_lazy('profile')
def form_valid(self,form):
form.instance.user = self.request.user
success_url = reverse_lazy('profilecreate')
return super(ProfileCreate,self).form_valid(form)
Urls.py
#for register
path('register/',views.CustomerRegistrationView.as_view(),name= 'register'),
#for CreateProfile
path('profilecreate/',views.ProfileCreate.as_view(),name= 'profilecreate'),
Also the Important thing is that when i have not setup the Logout Function then it working,But when i steup,Then this not redirect user to another page and stay at Registration Page.
You can use redirect instead, so that will be something like the below
Also another that i noticed is that your ProfileCreate doesnt to be a View i cant see any post or get function, if this will be a page you should add a function, in your case a post function.