def sign_up(request): form = CreateNewUser() registered = False if request.method == 'POST': form = CreateNewUser(request.POST) if form.is_valid(): user = form.save() registered=True user_profile = UserProfile(user=user) user_profile.save() #user profile's instance of model return HttpResponseRedirect(reverse('App_Login:login')) return render(request, 'App_Login/sign_up.html', context={'title':'signup . Instagram', 'form':form})
def sign_up(request): form = CreateNewUser() registered = False if request.method == 'POST': form = CreateNewUser(data=request.POST) if form.is_valid(): user = form.save() registered = True user_profile = UserProfile(user=user) user_profile.save() return HttpResponseRedirect(reverse('App_Login:login')) return render(request, 'Login_App/signup.html', context={ 'title': 'Sign up . Social', 'form': form })
class Meta: model = UserProfile() exclude = ('user', )
class Meta: model = UserProfile() #exclude = ('user',) fields = "__all__"