django问题

Python/PHP/Perl 开发与设计
回复
zuriaake2011
帖子: 64
注册时间: 2012-04-10 15:45
送出感谢: 4 次
接收感谢: 1 次

django问题

#1

帖子 zuriaake2011 » 2012-12-05 18:27

最近在看django文档

mysite中的urls.py代码是:


from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns(’’,
url(r’^polls/’, include(’polls.urls’)),
url(r’^admin/’, include(admin.site.urls)),
)


运行出现


invalid syntax (urls.py, line 9)
Request Method: GET
Request URL: http://localhost:8000/polls
Django Version: 1.4.2
Exception Type: SyntaxError
Exception Value:
invalid syntax (urls.py, line 9)
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/var/www/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
zuriaake2011
帖子: 64
注册时间: 2012-04-10 15:45
送出感谢: 4 次
接收感谢: 1 次

Re: django问题

#2

帖子 zuriaake2011 » 2012-12-05 18:46

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)

已解决,正确代码如上。下划线部分出错
回复

回到 “Python/Php/Perl”