1

I'm making a Django website, off of a tutorial I'm watching on http://youtube.com, and I'm having problemos. Here's my urls.py script:

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)),
)

And my output:

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

Please help?

Also, if you have a good tutorial I could follow, please link me it! Also, I would preferably like to use Mamp Pro for the databases. Help a n00b?

1
  • 1
    So, there is a function named by include and [...] is being use on it. Don't do that. Commented May 2, 2012 at 22:56

1 Answer 1

6

include is a function; you're subscripting it as if it was a list.

For example:

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

Since functions can't be subscripted, you get the error you posted. But, as can be seen in the commented examples, you should be calling the function using the () syntax:

(r'^', include('FirstBlog.apps.homepage.urls'))
#             ^                              ^
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! NOW, TO TEXT MATEEEE!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.