0

エラーを追跡するのに多くの時間を費やしましたが、エラーがどこにあるのか誰か追跡してもらえませんか?

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'),                        

)
4

3 に答える 3

6
$url(r'^tags/(?p<tag?\w+)/$', 'tagpage'),

文字を置換しますか? >

于 2012-09-13T06:40:21.753 に答える
4

たぶんエラーがあります: url(r'^tags/(?p<tag?\w+)/$', 'tagpage')? 私はそれがあるべきだと思います: url(r'^tags/(?p<tag>\w+)/$', 'tagpage').

于 2012-09-13T06:39:51.050 に答える
1

?のinと同様に、は大文字に>する必要があります。p

r'^tags/(?P<tag>\w+)/$'
于 2012-09-13T08:23:55.857 に答える