stephenmcd / django-forms-builder

Let users build forms in Django admin
BSD 2-Clause "Simplified" License
691 stars 281 forks source link

'bool' object is not callable #248

Open bdbais opened 4 years ago

bdbais commented 4 years ago

I've installed this module to try, on admin site I created a form and save it, when I viewed on site it send me this error:

'bool' object is not callable

File "projectX\venv\lib\site-packages\forms_builder\forms\views.py" in get

  1. if login_required and not request.user.is_authenticated():

Exception Type: TypeError at /forms_builder/test-form-builder/ Exception Value: 'bool' object is not callable

-------------- Possible fix: forms_builder\forms\views.py

def get(self, request, *args, **kwargs):
    context = self.get_context_data(**kwargs)
    login_required = context["form"].login_required
    username = request.POST.get('username')
    password = request.POST.get('password')
    user = authenticate(username=username, password=password)
    if login_required and user is not None:
    #if login_required and not request.user.is_authenticated():
        path = urlquote(request.get_full_path())
        bits = (settings.LOGIN_URL, REDIRECT_FIELD_NAME, path)
        return redirect("%s?%s=%s" % bits)
    return self.render_to_response(context)

modo24 commented 4 years ago

You need to import too:

from django.contrib.auth import authenticate

giriannamalai commented 4 years ago

Github source is not having this issue.