def register(request): extra_context = {} if get_settings().deny_registration_from < datetime.now(): extra_context['deny_registration_from'] = get_settings().deny_registration_from extra_context['admins'] = User.objects.filter(is_superuser=True) extra_context['trainers'] = Group.objects.get(name="Trainer").user_set.all() else: if request.method == 'POST': form = MyRegistrationForm(request.POST, domain=RequestSite(request).domain, use_https=request.is_secure()) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('registration_complete')) else: form = MyRegistrationForm() extra_context['form'] = form return render_to_response('registration/registration_form.html', extra_context, context_instance=RequestContext(request))
def register_user(request): if request.method == 'POST': form = MyRegistrationForm(request.POST) uform = UserDetailForm(request.POST) print "here" if form.is_valid(): print "Form1 is valid" if uform.is_valid(): print "Form2 is valid" user = form.save() userprofile = uform.save(commit=False) userprofile.user = user userprofile.save() return HttpResponseRedirect('/accounts/register_success') args = {} args.update(csrf(request)) args['form'] = MyRegistrationForm() args['uform'] = UserDetailForm() return render(request, 'register.html', args)
def make_account_view(request): if request.method == 'POST': form = MyRegistrationForm(request.POST) if form.is_valid(): user = form.save() return redirect("home") else: form = MyRegistrationForm() return render(request, 'accounts/make-account.html', {'form': form})
def signup_view(request): if request.method == 'POST': form = MyRegistrationForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect('dashboard:health') else: form = MyRegistrationForm() return render(request, 'accounts/signup.html', {'form': form})
def editProfile_view(request): if request.method == 'POST': form = MyRegistrationForm(request.POST, instance=request.user) if form.is_valid: form.save() return redirect('dashboard:profilePage') else: form = MyRegistrationForm(instance=request.user) args = {'form': form} return render(request, 'accounts/edit_profile.html', args)
def register(request): print request if request.method == 'POST': form = MyRegistrationForm(request.POST, request.FILES) if form.is_valid(): form.save(commit=True) return HttpResponseRedirect('/accounts/register/complete') else: form = MyRegistrationForm() token = {} token.update(csrf(request)) token['form'] = form return render(request, 'registration/registration_form.html', token)
def register(request): extra_context = {} if (not settings.REGISTRATION_POSSIBLE ) or get_settings().deny_registration_from < datetime.now(): extra_context['deny_registration_from'] = get_settings( ).deny_registration_from extra_context['admins'] = User.objects.filter(is_superuser=True) extra_context['trainers'] = Group.objects.get( name="Trainer").user_set.all() else: if request.method == 'POST': form = MyRegistrationForm(request.POST, domain=RequestSite(request).domain, use_https=request.is_secure()) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('registration_complete')) else: form = MyRegistrationForm() extra_context['form'] = form return render(request, 'registration/registration_form.html', extra_context)