user3511563
user3511563

Reputation: 397

DoesNotExist at /admin

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: [email protected]
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?

Upvotes: 0

Views: 381

Answers (1)

RodrigoOlmo
RodrigoOlmo

Reputation: 714

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.

Upvotes: 1

Related Questions