python-urls.py中的Django EOL
作者:互联网
当我启动django服务器并键入一些URL django时,总是给我一个EOL错误:
SyntaxError at /accounting/payments/
EOL while scanning string literal (urls.py, line 22)
Request Method: GET
Request URL: http://localhost:8000/accounting/payments/
Django Version: 1.4
Exception Type: SyntaxError
Exception Value:
EOL while scanning string literal (urls.py, line 22)
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.3
Python Path:
['/Users/Tone/Documents/Proyectos/macrogest/MacroTelecom',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/South-0.7.5-py2.7.egg',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_debug_toolbar-0.8.5-py2.7.egg',
'/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg',
'/Library/Python/2.7/site-packages/ipython-0.13-py2.7.egg',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL',
'/Users/Tone/Documents/django/django',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/Library/Python/2.7/site-packages',
'/Users/Tone/Documents/Django']
这是我的urls.py代码:
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('',
# Site control
url(r'^$', 'macrotelecom.base.views.home', name='home'),
url(r'^company/', include('macrotelecom.company.urls')),
url(r'^people/', include('macrotelecom.people.urls')),
url(r'^lines/', include('macrotelecom.lines.urls')),
url(r'^accounting/', include('macrotelecom.accounting.urls')),
url(r'^sales/', include('macrotelecom.sales.urls')),
url(r'^shop/', include('macrotelecom.shop.urls')),
url(r'^news/', include('macrotelecom.news.urls')),
url(r'^map/', 'macrotelecom.base.views.webmap', name='map'),
url(r'^error/$', 'macrotelecom.base.views.error', name='error'),
# Internal
url(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/img/favicon.ico'}),
url(r'^i18n/', include('django.conf.urls.i18n')),
#url(r'^admin/', include(admin.site.urls)),
url(r'^rosetta/', include('rosetta.urls')),
# User control
(r'^not_authorized/$', 'base.views.not_authorized'),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', 'django.contrib.auth.views.logout'),
(r'^password_change/$','django.contrib.auth.views.password_change'),
(r'^password_change/done/$','django.contrib.auth.views.password_change_done'),
(r'^password_reset/$','django.contrib.auth.views.password_reset'),
(r'^password_reset/done/$','django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$','django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$','django.contrib.auth.views.password_reset_complete'),
)
第22行与Favicon网址相对应,我以为可能是scape字符或类似的东西(我在注释中加了#),但没有用,总是说EOL错误,可能是什么?
解决方法:
该文件(至少是您发布的部分)没有任何语法错误.有时,错误似乎来自其他文件.
只需在python myapp / views.py上运行解释器,即可检查您最近编辑的文件.如果出现NameError或ImportError或运行正常,则myapp / views.py中没有语法错误,因此请尝试其他文件.
标签:eol,django-urls,python,django 来源: https://codeday.me/bug/20191201/2078070.html