超出/ admin /最大递归深度的RuntimeError; django教程

时间:2015-08-21 19:05:22

标签: python django python-2.7 django-models

我正在使用app教程构建Django,在尝试访问管理页面时,我收到以下错误。我有DEBUG = True并且空ALLOWED_HOSTS

环境:

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

Django版本:1.8.4 Python版本:2.7.6

Installed Applications:
    ('django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls')

Installed Middleware:
    ('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',
    'django.middleware.security.SecurityMiddleware')

回溯:

File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/contrib/admin/sites.py" in wrapper
  254.                 return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/utils/decorators.py" in _wrapped_view
  110.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/contrib/admin/sites.py" in inner
  223.                 if request.path == reverse('admin:logout', current_app=self.name):
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in reverse
  550.                 app_list = resolver.app_dict[ns]
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in app_dict
  352.             self._populate()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in _populate
  308.                     for name in pattern.reverse_dict:
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in reverse_dict
  338.             self._populate()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in _populate
  308.                     for name in pattern.reverse_dict:
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.4-py2.7.egg/django/core/urlresolvers.py" in reverse_dict
  338.             self._populate()

我在教程2上 https://docs.djangoproject.com/en/dev/intro/tutorial02/

urls.py

from django.conf.urls import include,url
from django.contrib import admin
from . import views

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

models.py

import datetime
from django.db import models
from django.utils import timezone

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    # def __str__(self):              # __unicode__ on Python 2
    #     return self.question_text
    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField()
    #def __str__(self):              # __unicode__ on Python 2
    #    return self.choice_text

这是我的目录结构:  polls/urls.py

0 个答案:

没有答案