我是Django的新手,并且在我自己分支之前想过我会经历一些教程.我正在尝试编写此处描述的日历应用程序:http://lightbird.net/dbe/cal1.html.但是,他们的URLconfigs似乎不适合我,因为我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
如果有人能指出我正确的方向,我将不胜感激!
我对Java相对较新,并且对以下查询有任何帮助表示感谢.我定义了两类-为了简单起见,我们称他们为A和B.Class A有一个名为的方法methodA,并Class B有一个名为的方法methodB.这两个类的对象包含在被ArrayList调用的中container.我需要做的是ArrayList根据对象的类型循环并调用不同的方法.
这是我目前的代码:
for (Object item : container) {
if (item instanceof A) {
item.methodA()
} else if (item instanceof B) {
item.methodB()
}
}
Run Code Online (Sandbox Code Playgroud)
我的IDE(NetBeans)不会编译上面的代码,因为item类型Object没有methodA或methodB.有没有其他方法来编写循环来完成我需要它做的事情?谢谢.