0

I'm getting this error:

DoesNotExist at /admin
Quiz matching query does not exist. Lookup parameters were {'url': u'admin'}

But, I already checked other solution in SO, about removing #'django.contrib.sites', which doesn't work for me.

These are my installed apps:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    #'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'simulado',
    'multichoice',
    'django.contrib.admin',
)

This is my urls.py

from django.conf.urls import patterns, include, url


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'quiz.views.home', name='home'),
    # url(r'^quiz/', include('quiz.foo.urls')),


    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),

    ####################
    # quiz base url    
    url(r'^$', 'simulado.views.index'),   

    # quiz category list    
    url(r'^category/(?P<slug>[^\.]+)', 'simulado.views.view_category', name='view_quiz_category'),

    #  cart 
    #url(r'^carrinho$', 'simulado.views.carrinho'),
    #url(r'^carrinho2$', 'simulado.views.carrinho2', name = "carrinho2"),
    #url(r'^buyItem$', 'simulado.views.buyItem', name = "buyItem"),

    #  progress 
    url(r'^progress/$', 'simulado.views.progress'),
    url(r'^progress$', 'simulado.views.progress'),


    #  passes variable 'quiz_name' to quiz_take view
    url(r'^(?P<quiz_name>[\w-]+)/$',
        'simulado.views.quiz_take'),  #  quiz/

    url(r'^(?P<quiz_name>[\w-]+)$',
        'simulado.views.quiz_take'),  #  quiz

    url(r'^(?P<quiz_name>[\w-]+)/take/$',
        'simulado.views.quiz_take'),  #  quiz/take/

    url(r'^(?P<quiz_name>[\w-]+)take$',
        'simulado.views.quiz_take'),  #  quiz/take

)

This is the results of my syncdb

Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table simulado_category
Creating table simulado_quiz
Creating table simulado_progress
Creating table simulado_sitting
Creating table multichoice_question_quiz
Creating table multichoice_question
Creating table multichoice_answer
Creating table django_admin_log

You just installed Django's auth system, which means you don't have any superusers defined.

    admin.autodiscover()
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'filipeferminiano'): 
Email address: filipe.ferminiano@gmail.com
Password: 
Password (again): 
Superuser created successfully.

This is the traceback

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin

Django Version: 1.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'simulado',
 'multichoice',
 'django.contrib.admin')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/filipeferminiano/Documents/django/quiz/quiz/simulado/views.py" in quiz_take
  71.     quiz = Quiz.objects.get(url=quiz_name.lower())
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py" in get
  143.         return self.get_query_set().get(*args, **kwargs)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py" in get
  401.                 (self.model._meta.object_name, kwargs))

Exception Type: DoesNotExist at /admin
Exception Value: Quiz matching query does not exist. Lookup parameters were {'url': u'admin'}

Then django creates a superuser not showing any error. What should I do?

Community
  • 1
  • 1
user3511563
  • 397
  • 2
  • 5
  • 18
  • 1
    Can you provide the entire stack trace instead of your paraphrased version of it? :) Also, your urls.py is "paraphrased." When it comes to code, helpful to include the actual code. Finally, please include the link to the "other solution" you mentioned. There's just not enough detail here to know what's going wrong, though there are plenty of possibilities. – the911s Jun 01 '14 at 16:41
  • I updated the code. Take a look – user3511563 Jun 01 '14 at 16:57
  • You're getting this stack trace when you try to navigate to i.e. http://localhost:8000/admin in your browser? DoesNotExist suggests to me that it's querying for a model (Quiz) in the database and getting an empty set. The admin page handles this case well since it's pretty common, so I'm not sure why you'd see that based on the info you've provided. Maybe someone else will spot the problem, but I think your best bet is to post or look at the detailed part of the stack trace where the actual error occurred (the line-by-line part). – the911s Jun 01 '14 at 17:36
  • For reference, this is the official documentation on DoesNotExist. Pretty straightforward. Hope it gives you an idea. I would first check your Quiz model and make sure it's ok, then perhaps delete and re-sync your DB (a luxury you have since you just created it), then restart your server. Also look at admin.py and make sure you aren't trying to display a model that doesn't exst. https://docs.djangoproject.com/en/dev/ref/exceptions/#objectdoesnotexist-and-doesnotexist – the911s Jun 01 '14 at 17:49
  • @Andy what do you mean with stack? I think I misusderstand you. I paste all the traceback now. – user3511563 Jun 01 '14 at 21:14

1 Answers1

1

I found the problem.

You are trying to get localhost:8000/admin without the slash at the end, and there is a URL in urls.py that matches that:

url(r'^(?P<quiz_name>[\w-]+)$',
    'simulado.views.quiz_take'),  #  quiz

The exception is raised in that view, it has nothing to do with the admin. Fix your URLs and that's all.

RodrigoOlmo
  • 704
  • 1
  • 5
  • 10