Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python DoesNotExist at/admin_Python_Django - Fatal编程技术网

Python DoesNotExist at/admin

Python DoesNotExist at/admin,python,django,Python,Django,我得到了这个错误: DoesNotExist at /admin Quiz matching query does not exist. Lookup parameters were {'url': u'admin'} 但是,我已经检查了其他网站,所以,关于删除“django.contrib.sites”,这对我不起作用 这些是我安装的应用程序: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contentt

我得到了这个错误:

DoesNotExist at /admin
Quiz matching query does not exist. Lookup parameters were {'url': u'admin'}
但是,我已经检查了其他网站,所以,关于删除“django.contrib.sites”,这对我不起作用

这些是我安装的应用程序:

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',
)
这是我的URL.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

)
这是回溯

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'}
然后django创建一个超级用户,不显示任何错误。 我该怎么办?

我发现了问题

您正在尝试获取
localhost:8000/admin
,但末尾没有斜杠,并且URL.py中有一个URL与以下内容匹配:

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

在该视图中引发了异常,它与管理员无关。修复您的URL,就这样。

您能提供整个堆栈跟踪而不是您的解释版本吗?:)此外,您的urls.py是“解释的”。当涉及到代码时,包含实际代码会很有帮助。最后,请附上您提到的“其他解决方案”的链接。这里没有足够的细节来知道出了什么问题,尽管有很多可能性。我更新了代码。看一看,当您尝试导航到(即在浏览器中)时,是否得到此堆栈跟踪?DoesNotExist向我建议,它在数据库中查询模型(测验)并得到一个空集。管理页面很好地处理了这种情况,因为它非常常见,所以我不确定根据您提供的信息,您为什么会看到这种情况。也许其他人会发现这个问题,但我认为最好的办法是发布或查看堆栈跟踪中发生实际错误的详细部分(逐行部分)。作为参考,这是关于DoesNotExist的官方文档。很简单。希望它能给你一个想法。我会先检查你的测验模型,确保它正常,然后删除并重新同步你的数据库(这是你刚创建数据库后的奢侈),然后重新启动你的服务器。还要查看admin.py,确保您没有试图显示不存在的模型@安迪,你说斯塔克是什么意思?我想我误解你了。我现在粘贴所有回溯。
url(r'^(?P<quiz_name>[\w-]+)$',
    'simulado.views.quiz_take'),  #  quiz