Exemplo n.º 1
0
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/')
Exemplo n.º 2
0
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/')
Exemplo n.º 3
0
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/')
Exemplo n.º 4
0
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/')