我花了很多时间来追踪我的错误,但我找不到任何人都可以找出错误在哪里吗?
Environment:
Request Method: GET
Request URL: [http://127.0.0.1:8000/blog/archives]
Django Version: 1.4.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'taggit',
'blog')
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/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
89. response = middleware_method(request)
File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py" in process_request
67. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in is_valid_path
531. resolve(path, urlconf)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
420. return get_resolver(urlconf).resolve(path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
300. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
300. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
196. match = self.regex.search(path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in regex
162. compiled_regex = re.compile(self._regex, re.UNICODE)
File "/usr/lib/python2.7/re.py" in compile
190. return _compile(pattern, flags)
File "/usr/lib/python2.7/re.py" in _compile
242. raise error, v # invalid expression
Exception Type: error at /blog/archives
Exception Value: unexpected end of pattern
这是我的 URLS.PY
from django.conf.urls import patterns, include, url
from django.views.generic import ListView, DetailView
from blog.models import Post
urlpatterns = patterns('',
url(r'^$',
ListView.as_view(
queryset=Post.objects.order_by("-created")[:2],
template_name="blog.html")),
url(r'^(?p<pk>\d+)/$',
DetailView.as_view(
model=Post,
template_name="post.html")),
url(r'^archives/$',
ListView.as_view(
queryset=Post.objects.all().order_by("-created"),
template_name="archives.html")),
url(r'^tags/(?p<tag?\w+)/$', 'tagpage'),
)