I'm new to Django and thought I'd go through a few tutorials before branching out on my own. I'm trying to program the calendar app described here: http://lightbird.net/dbe/cal1.html . However, their URLconfigs don't seem to be working for me as I get the following error:
TypeError at /admin/
'str' object is not callable
Request Method: GET
Request URL: http://ec2-23-20-82-228.compute-1.amazonaws.com:8000/admin/
Django Version: 1.4
Exception Type: TypeError
Exception Value:
'str' object is not callable
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response, line 111
Python Executable: /usr/bin/python
Python Version: 2.7.3
If anyone could point me in the right direction, it'd be greatly appreciated!
I'm pretty sure your error is caused by a wrong url conf, the link you posted describes only 2 urlpatterns not the entire url conf:
(r"^(\d+)/$", "main"),
(r"", "main"),
You can only refer to a string "main" if you setup the prefix correctly, so in your case you probably have a structure like:
/project
/app
views.py
urls.py
your url conf should be:
urlpatterns = patterns('app.views',
(r"^(\d+)/$", "main"),
(r"", "main"),
)
You can also import the function directly like so:
from app.views import main
urlpatterns = patterns('',
(r"^(\d+)/$", main),
(r"", main),
)
I think it's also bad practice to have two urls pointing to the same view, I would rather create a redirect for the second one and let the view determine if there's parameters to handle
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.