When logging in, create a profile, But when logging out and then logging in with that same username, It again says to me to create a profile and creates two profiles instead of one.
#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('profilecreate')
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('profile')
return super(ProfileCreate,self).form_valid(form)
here are my URLs
#for register
path('register/',views.CustomerRegistrationView.as_view(),name= 'register'),
#for CreateProfile
path('profilecreate/',views.ProfileCreate.as_view(),name= 'profilecreate'),
when User Created and I remove the loginrequiredmixin from profilecreateview. It give me an error of Page No Found With This Url:127.0.0.1:8000/accounts/login/?next=/profilecreate. It does not go to Profile Create View because it is not logged in but just Registered. And I want the User Go to Profilecreateview only one time. Later he can Update it. –