def profile_view(request): if request.session['username']: a = Create.objects.get(username=request.session['username']) try: b=Profile.objects.get(user=a) except: b=Profile(user=a) b.save() b=Profile.objects.get(user=a) return render(request,'trackuser/profile_view.html', {'profile':b}) else: return HttpResponseRedirect('/login/')
def profile_view(request): if request.session['username']: a = Create.objects.get(username=request.session['username']) try: b = Profile.objects.get(user=a) except: b = Profile(user=a) b.save() b = Profile.objects.get(user=a) return render(request, 'trackuser/profile_view.html', {'profile': b}) else: return HttpResponseRedirect('/login/')
def profile(request): if request.session['username']: if request.method == 'POST': a = Create.objects.get(username=request.session['username']) try: b = Profile.objects.get(user=a) except: b = Profile(user=a) b.save() b = Profile.objects.get(user=a) form = ProfileForm(request.POST, instance=b) if form.is_valid(): # Save the new category to the database. form.save() # Now call the index() view. # The user will be shown the homepage. #return userlist(request) return HttpResponseRedirect('/login/') else: # The supplied form contained errors - just print them to the terminal. return render(request, 'trackuser/profile.html', {'form': form}) else: a = Create.objects.get(username=request.session['username']) try: b = Profile.objects.get(user=a) except: b = Profile(user=a) b.save() b = Profile.objects.get(user=a) form = ProfileForm(instance=b) return render(request, 'trackuser/profile.html', {'form': form}) else: # If the request was not a POST, display the form to enter details. return HttpResponseRedirect('/login/')
def profile(request): if request.session['username']: if request.method == 'POST' : a = Create.objects.get(username=request.session['username']) try: b = Profile.objects.get(user=a) except: b = Profile(user=a) b.save() b = Profile.objects.get(user=a) form = ProfileForm(request.POST,instance=b) if form.is_valid(): # Save the new category to the database. form.save() # Now call the index() view. # The user will be shown the homepage. #return userlist(request) return HttpResponseRedirect('/login/') else: # The supplied form contained errors - just print them to the terminal. return render(request,'trackuser/profile.html',{'form':form}) else: a= Create.objects.get(username=request.session['username']) try: b = Profile.objects.get(user=a) except: b=Profile(user=a) b.save() b=Profile.objects.get(user=a) form = ProfileForm(instance=b) return render(request,'trackuser/profile.html',{'form':form}) else: # If the request was not a POST, display the form to enter details. return HttpResponseRedirect('/login/')