Django debugger vs running From terminal

Viewed 17

I'm trying to authenticate a basic django webapp with my firebase cloud db.

So the problem is when I login normally providing the appropriate username and password, the login is sucessfull and i get redirected to the home page.

But when I run a debugger I get an error saying :

Internal Server Error: /login/ Traceback (most recent call last): 
File "c:\Users\moham\OneDrive\Desktop\Granular\web solution\web_solution\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
  response = get_response(request)   
File "c:\Users\moham\OneDrive\Desktop\Granular\web solution\web_solution\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)   
File "C:\Users\moham\OneDrive\Desktop\Granular\web solution\Chosen_granular\apps\authentication\views.py", line 26, in login_view
  if (firebase_authentication(user.email,password)):
  **AttributeError: 'NoneType' object has no attribute 'email'**

And this is how my login view function looks like.

def login_view(request):

    form = LoginForm(request.POST or None)
    msg = None
    if request.method == "POST":

        if form.is_valid():
            username = form.cleaned_data.get("username")
            password = form.cleaned_data.get("password")
            user = authenticate(username=username, password=password)
            if (firebase_authentication(user.email,password)):

                #user = auth.get_user_by_email(user.email)
                #request['uid']=user.uid

                login(request, user)
                return redirect("/")
            else:
                msg = 'Invalid credentials'
        else:
            msg = 'Error validating the form'

    return render(request, "accounts/login.html", {"form": form, "msg": msg})
0 Answers
Related