我刚刚为我的 Django 页面添加了一个 css 文件。但我收到错误消息:
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
101. request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
298. for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in url_patterns
328. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in urlconf_module
323. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
35. __import__(name)
File "C:\Python27\PythonProjects\testproject\testproject\urls.py" in <module>
25. (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': site_media}),
Exception Type: TypeError at /
Exception Value: 'tuple' object is not callable
在我的 urls.py 文件中,我包含了以下几行:
site_media = os.path.join(os.path.dirname(__file__), 'site_media')
urlpatterns = patterns('',
..................
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': site_media}),
)
错误消息告诉我错误来自urlpatterns
. 我的site_media
文件夹存储在 中C:/Python27/PythonProjects/testproject
,我的 css 文件在site_media
文件夹中。谢谢!