Natiq Vahabov
Natiq Vahabov

Reputation: 504

django simple debugging gives strange result

I experience something interesting in my project, I'm using Oracle as db. Inside js when I call home view function strange things happen. How can it happen?

js

setInterval(function() {
    var div = document.querySelector("#counter");
    var count = div.textContent * 1 - 1;
    div.textContent = count;
    if (count <= 0) {
        window.location.href="{% url 'home' %}";
    }
}, 1000);

home

def home(request):
# First check IP address
if request.user == AnonymousUser():
    ip_address  = get_ip_address(request)
    user_logged = login_ip_address(request,ip_address,request.user)

if request.user.is_authenticated:
    print "1"
    getNotifications(request)
    print "2"
    requests = getRequests(request)
    print "3"
    user_categories_names = getUserCategories(request)
    print "4"
    chart = []

    if requests:
        print "5"
        openR = requests.filter(status="open").count()
        print "6"
        closedR = requests.filter(status="closed").count()
        print "7"
        lockedR = requests.filter(status__contains="lock").count()
        print "8"
        if openR>0 or closedR>0 or lockedR>0:
            print "9"
            chart=[openR,closedR,lockedR]
            print "10"
        else:
            print "11"
            deletedR = requests.filter(status="deleted").count()
            chart=[deletedR]
    #allCategoryRequests = getAllCategoryRequests(request,user_categories_requests)

    #requests = list(chain(sentRequestResult, tagRequests, parentRequestResult))
    print "12"
    data = {'requests':requests,'catNames':user_categories_names,'chart':chart,'activeCategory':'taggedRequests'}
    template = "home.html"
    print "13"
    #pdb.set_trace()
    return render(request,template,data)
    print "14"
else:
    print "15"
    return HttpResponseRedirect('accounts/login')

Output

1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 4 5 2 3 6 7 4 8 5 9 10 12 13 6 1 7 8 9 10 12 13 2 3 2 3 4 1 2 3 4 5 Killed: 9

Upvotes: 1

Views: 33

Answers (1)

Natiq Vahabov
Natiq Vahabov

Reputation: 504

the problem was in js, it was sending multiple redirection. So it should be if (count == 0).

Upvotes: 2

Related Questions