开发者

Django: error at / bad character in group name

开发者 https://www.devze.com 2023-02-15 01:36 出处:网络
I was following Apress - Practical Django Project by James Bennet and I got this nasty error out of the blue. Could you help me?

I was following Apress - Practical Django Project by James Bennet and I got this nasty error out of the blue. Could you help me?

Here it goes:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.2.5
Python Version: 2.5.4

Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.admin',
 'django.contrib.flatpages',
 'cms.search',
 'coltrane',
 'tagging']

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 "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  91.                         request.path_info)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/pyth开发者_开发技巧on2.5/site-packages/django/core/urlresolvers.py" in resolve
  215.             for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_url_patterns
  244.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
  239.             self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/Users/danielcorreia/Sites/test_Django/cms/../cms/urls.py" in <module>
  21.   (r'', include('django.contrib.flatpages.urls')),
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in patterns
  24.             t = url(prefix=prefix, *t)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in url
  41.         return RegexURLPattern(regex, view, kwargs, name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in __init__
  89.         self.regex = re.compile(regex, re.UNICODE)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in compile
  188.     return _compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in _compile
  241.         raise error, v # invalid expression

Exception Type: error at /
Exception Value: bad character in group name

Oh! I'm a newbie to Django. Please be gentle :)

Here's the urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^cms/', include('cms.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
    (r'tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': '/Users/danielcorreia/Sites/tinymce/jscripts/tiny_mce' }),
    (r'^search/$', 'cms.search.views.search'),
    (r'^weblog/$', 'coltrane.views.entries_index'),
    (r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
    (r'', include('django.contrib.flatpages.urls')),
)


(r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),

Change to:

(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),

Note the closing angle bracket for the year group.

0

精彩评论

暂无评论...
验证码 换一张
取 消