Django url.py语法错误

时间:2014-04-17 18:33:03

标签: python django

我收到以下错误,但我无法弄清楚语法是否有错误。

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  89.                     response = middleware_method(request)
File "/Library/Python/2.7/site-packages/django/middleware/common.py" in process_request
  67.             if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in is_valid_path
  531.         resolve(path, urlconf)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in resolve
  420.     return get_resolver(urlconf).resolve(path)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in resolve
  298.             for pattern in self.url_patterns:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  328.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  323.             self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/Users/nir/Documents/candycode/wsgi/openshift/../openshift/urls.py" in <module>
  18.     url(r'^contact/', include('openshift.contactapplication.urls')),
File "/Library/Python/2.7/site-packages/django/conf/urls/__init__.py" in include
  24.         urlconf_module = import_module(urlconf_module)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py" in import_module
 35.     __import__(name)

Exception Type: SyntaxError at /contact/addcontact
Exception Value: invalid syntax (urls.py, line 15)

这是我的主要urls.py,我正在尝试将其链接到contactapplication app文件夹中的另一个urls.py:

urlpatterns = patterns('',

url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'openshift.views.home_view'),
url(r'^contact/', include('openshift.contactapplication.urls')), <- points here

#for nir's local development purposes
url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': '/Users/nir/documents/candycode/wsgi/static', 'show_indexes': True}),
)

可能导致此语法错误的原因是什么?从我的角度来看,语法似乎是正确的。

编辑: 这是我的contactapplication / urls.py -

#contactapplication urls.py 

from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()


urlpatterns = patterns('',

    url(r'^addcontact$', 'openshift.contactapplication.views.contactus_page',
)

0 个答案:

没有答案