2012-05-02 8 views
1

私はhttp://youtube.comを見ているチュートリアルの外に、Djangoのウェブサイトを作っていますが、私は問題を抱えています。ここに私のurls.pyスクリプトがあります:DjangoのURLパターンを「インクルード」するとき、「function」オブジェクトにサブスクリプトがありませんか?

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

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

urlpatterns = patterns('', 
    (r'^', include['FirstBlog.apps.homepage.urls']), 
    # Examples: 
    # url(r'^$', 'FirstBlog.views.home', name='home'), 
    # url(r'^FirstBlog/', include('FirstBlog.foo.urls')), 

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

    # Uncomment the next line to enable the admin: 
    # url(r'^admin/', include(admin.site.urls)), 
) 

そして、私の出力:

TypeError at/
'function' object is not subscriptable 
Request Method: GET 
Request URL: http://127.0.0.1:8000/ 
Django Version: 1.4 
Exception Type: TypeError 
Exception Value:  
'function' object is not subscriptable 
Exception Location: /Users/thor/Sites/FirstBlog/FirstBlog/urls.py in <module>, line 8 
Python Executable: /usr/bin/python 
Python Version: 2.7.1 
Python Path:  
['/Users/thor/Sites/FirstBlog', 
'/Library/Python/2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', 
'/Library/Python/2.7/site-packages'] 
Server time: Wed, 2 May 2012 17:42:04 -0500 

助けてください?

また、良いチュートリアルをお持ちの場合は、私に連絡してください!また、データベース用にMamp Proを使用することをお勧めします。ヘルプn00b?

+1

を、include'と ''という名前の関数がある[...]は 'それに使用されています。それをしないでください。 –

答えて

5

includeは関数です。あたかもそれがリストであるかのように添え字を付けています。例えば

:関数は添字をすることはできませんので

apples = [ 'Granny Smith', 'Russet' ] 
red_apple = apples[1] # <-- Subscripting a list 

、あなたはあなたが投稿エラーが発生します。コメントの例に見られるようにしかし、あなたは()の構文を使用して機能を呼び出すようになります。だから、

(r'^', include('FirstBlog.apps.homepage.urls')) 
#   ^       ^
+0

ありがとう!今、MATEEEEのテキストに! –

関連する問題