Coder Social home page Coder Social logo

Comments (4)

shivakumargn avatar shivakumargn commented on July 17, 2024 12

Django 1.10 seems to have introduced a change that is causing the error.

The get_form inside the view needs to change as below
def get_form(self, form_class=None): if form_class is None: form_class = self.get_form_class()

from django_quiz.

ALee008 avatar ALee008 commented on July 17, 2024

Hey,
I got the same problem while migrating to Django 1.11.13. Setting the default to None results in a TypeError 'NoneType' object is not callable.

This is the Traceback:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/q/first/take/

Django Version: 1.11.13
Python Version: 2.7.12
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'quiz',
'multichoice',
'true_false',
'essay')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:

File "C:\Python27\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
249. response = self._get_response(request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Python27\lib\site-packages\django\views\generic\base.py" in view
68. return self.dispatch(request, *args, **kwargs)

File "C:\Python27\lib\site-packages\django_quiz_app-0.5.1-py2.7.egg\quiz\views.py" in dispatch
155. return super(QuizTake, self).dispatch(request, *args, **kwargs)

File "C:\Python27\lib\site-packages\django\views\generic\base.py" in dispatch
88. return handler(request, *args, **kwargs)

File "C:\Python27\lib\site-packages\django\views\generic\edit.py" in get
174. return self.render_to_response(self.get_context_data())

File "C:\Python27\lib\site-packages\django_quiz_app-0.5.1-py2.7.egg\quiz\views.py" in get_context_data
190. context = super(QuizTake, self).get_context_data(**kwargs)

File "C:\Python27\lib\site-packages\django\views\generic\edit.py" in get_context_data
93. kwargs['form'] = self.get_form()

File "C:\Python27\lib\site-packages\django_quiz_app-0.5.1-py2.7.egg\quiz\views.py" in get_form
168. return form_class(**self.get_form_kwargs())

Exception Type: TypeError at /q/first/take/
Exception Value: 'NoneType' object is not callable

I tried fixing it by adding these lines in the view:

    if form_class is None:
        form_class = QuestionForm

which results in an AttributeError claiming:
'Question' object has no attribute 'get_answers_list'

Any advice is much appreciated. Thank you.

from django_quiz.

jameskomo avatar jameskomo commented on July 17, 2024

Django 1.10 seems to have introduced a change that is causing the error.

The get_form inside the view needs to change as below
def get_form(self, form_class=None): if form_class is None: form_class = self.get_form_class()

which function exactly? I am having the same challenge

from django_quiz.

jameskomo avatar jameskomo commented on July 17, 2024

I cannot find out why I've got this error. Any idea?

Traceback:

File "C:\Python35\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)

File "C:\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File "C:\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Python35\lib\site-packages\django\views\generic\base.py" in view
68. return self.dispatch(request, *args, **kwargs)

File "C:\mysite\quiz\views.py" in dispatch
155. return super(QuizTake, self).dispatch(request, *args, **kwargs)

File "C:\Python35\lib\site-packages\django\views\generic\base.py" in dispatch
88. return handler(request, *args, **kwargs)

File "C:\Python35\lib\site-packages\django\views\generic\edit.py" in get
174. return self.render_to_response(self.get_context_data())

File "C:\mysite\quiz\views.py" in get_context_data
191. context = super(QuizTake, self).get_context_data(**kwargs)

File "C:\Python35\lib\site-packages\django\views\generic\edit.py" in get_context_data
93. kwargs['form'] = self.get_form()

Exception Type: TypeError at /hell/take/
Exception Value: get_form() missing 1 required positional argument: 'form_class'

Did you get any solution to this? I have the same problem

from django_quiz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.