tomwalker / django_quiz

This is a configurable quiz app for Django.
614 stars 354 forks source link

Getting error while creating a quiz and taking it. #59

Open mahesh-ziffi opened 8 years ago

mahesh-ziffi commented 8 years ago

I' m noob to Django and was trying to run the app. I simply downloaded the app and getting the following error.

Environment:

Request Method: GET Request URL: http://127.0.0.1:8000/quiz/test1/take/

Django Version: 1.9.1 Python Version: 2.7.10 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'true_false', 'quiz', 'multichoice', 'essay', 'aetsv_apps_2.agriera_apps.mysite', 'aetsv_apps_2.agriera_apps.myapp'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = wrapped_callback(request, _callback_args, *_callback_kwargs)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django/views/generic/base.py" in view

  1. return self.dispatch(request, _args, *_kwargs)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django_quiz_app-0.5.1-py2.7.egg/quiz/views.py" in dispatch

  1. self.quiz)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django_quiz_app-0.5.1-py2.7.egg/quiz/models.py" in user_sitting

  1. sitting = self.new_sitting(user, quiz)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django_quiz_app-0.5.1-py2.7.egg/quiz/models.py" in new_sitting

  1. if len(question_set) == 0:

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django/db/models/query.py" in len

  1. self._fetch_all()

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all

  1. self._result_cache = list(self.iterator())

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/model_utils/managers.py" in iterator

  1. sub_obj = self._get_sub_obj_recurse(obj, s)

File "/home/mahesh/anaconda2/lib/python2.7/site-packages/model_utils/managers.py" in _get_sub_obj_recurse

  1. node = getattr(obj, rel)

Exception Type: AttributeError at /quiz/test1/take/ Exception Value: 'long' object has no attribute 'essay_question'

mjsisley commented 8 years ago

On line 315 of quiz/models.py:

Replace:

question_set = question_set.values_list('id', flat=True) with question_set = [item.id for item in question_set]

I think the issue is that model_utils changed and that question_set is different. I am not sure though, and this got it working for me.

devht commented 8 years ago

I faced the mentioned error even with this change above, however, this issue is resolved by updating django-model-utils (tested on version 2.5.2) pip install django-model-utils==2.5.2

ghost commented 7 years ago

У мене та сама помилка, будь ласка, допоможіть