def signup(request): rider = get_rider(request) if rider: return HttpResponseRedirect('/entourage/') if request.method == 'POST': form = RegistrationForm(request.POST, request.FILES) if form.is_valid(): rider = form.save(commit=False) if not rider.avatar: fname = generate_filename(rider, 'default.jpg') rider.avatar = fname default = settings.MEDIA_ROOT + 'riders/default.jpg' with open(default) as default: with open(fname, 'w') as f: f.write(default.read()) rider.save() else: return render(request, 'entourage/signup.html', {'form': form}) return HttpResponseRedirect('/entourage/login') else: form = RegistrationForm() return render(request, 'entourage/signup.html', {'form': form})
def register(request): """ User registration view. """ if request.method == 'POST': form = RegistrationForm(data=request.POST) if form.is_valid(): user = form.save() return redirect('/') else: form = RegistrationForm() return render_to_response('register.html', { 'form': form, }, context_instance=RequestContext(request))
def register_new_user(request): if request.method == 'POST': #usernamE = request.POST.get('username', '') #password = request.POST.get('password', '') #emaiL = request.POST.get('email', '') #phonE = request.POST.get('phone_number', '') form = RegistrationForm(data = request.POST) if form.is_valid(): user = form.save() return HttpResponseRedirect('/online_store/register_success') else: return HttpResponseRedirect('online_store/loggedin.html') else: form = RegistrationForm() args = {} args.update(csrf(request)) args['form'] = form return render_to_response('invalid_login.html', args)