S.Ali
S.Ali

Reputation: 692

attribute error 'function' object has no attribute 'has_header'

i have been encountered by this error

'function' object has no attribute 'has_header'

my url file contans

 url(r'^HighDefs/$', list_HighDefs),

and i have a view defined with the name

list_HighDefs

in views file. I dont know whats wrong.

the view contains

def list_HighDefs(request):
user_logger = Logger()
user_logger.log_stack()


if user_object:
    email = user_object.email
    uname = user_object.first_name+' '+user_object.last_name

    try:
        row = allapps_models.highdef.objects.filter(user_email=email, show_status=1)


    except Exception:

         return error_page(request)

    highdefs = []

    for m in row:
        order_product = int(m.m_id)
        state = m.state

        try:
            category = checkout_models.state.objects.get(pk=product).premature.category.all()
            category = category[0].pk
        except:

            category = 0


        if int(category) == 2:
            if state != 's':
                highdefs.append(m)


    return render_to_response('main/HighDefs.html',{'request': request, 'highdefs': highdefs, 'uname' :uname, 'email': email}, context_instance=RequestContext(request))

else:
    return(login)

Upvotes: 2

Views: 10366

Answers (2)

Alasdair
Alasdair

Reputation: 309089

Your view must return an HttpResponse object.

It does this for one branch of your if statement:

return render_to_response(...)

But not in the else branch.

return(login)

If login is a view function that returns an HttpResponse object, then you can change your return statement to

return login(request)

However, I suspect you want to redirect the user to your login page instead. In that case, change your code to:

from django.http import HttpResponseRedirect
return HttpResponseRedirect('/login/')

where /login/ is the url of your login page.

Upvotes: 5

Daniel Roseman
Daniel Roseman

Reputation: 599956

The last line of your view is return login (don't know why you're wrapping your returns in parentheses, it's unnecessary). But presumably login is a function, and you're not calling it. I expect you mean to do return login() or return login(request).

Upvotes: 4

Related Questions