Python “区域”对象不可调用

Python “区域”对象不可调用,python,orm,pony,Python,Orm,Pony,我在Mysql上有数据库,在项目中我在Flask中使用pony orm。我需要从数据库中获取索引为1的行 这里我有在应用程序中路由的路由 routes.py 这里我有我的数据库模型 models.py 当我在浏览器地址localhost:8888/中打开时,我收到下一个错误 当我犯错的时候?我很愚蠢!这里是解决方案: def user(): c = Area[1] name = c.name return name 看起来您正在尝试调用类而不是实例区域[1]是的,它不应

我在Mysql上有数据库,在项目中我在Flask中使用pony orm。我需要从数据库中获取索引为1的行

这里我有在应用程序中路由的路由

routes.py 这里我有我的数据库模型

models.py 当我在浏览器地址localhost:8888/中打开时,我收到下一个错误
当我犯错的时候?

我很愚蠢!这里是解决方案:

def user():
    c = Area[1]
    name = c.name
    return name

看起来您正在尝试调用类而不是实例区域[1]是的,它不应该是区域[1]而不是区域[1]?如果a.id==1,请尝试为区域内的对象选择此selecta。现在我得到TypeError:“Query”对象不可调用
from pony.orm import *
import config

db = Database()


class Country(db.Entity):
    id = PrimaryKey(int,auto=True)
    name = Required(str,100)
    area = Set("Area")


class Area(db.Entity):
    id = PrimaryKey(int, auto=True)
    name = Required(str, 100)
    country = Required(Country)
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\flask\app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Python34\lib\site-packages\flask\app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "C:\Python34\lib\site-packages\flask\app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Python34\lib\site-packages\flask\_compat.py", line 33, in reraise
    raise value
  File "C:\Python34\lib\site-packages\flask\app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Python34\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request
    response = self.make_response(rv)
  File "C:\Python34\lib\site-packages\flask\app.py", line 1577, in make_response
    rv = self.response_class.force_type(rv, request.environ)
  File "C:\Python34\lib\site-packages\werkzeug\wrappers.py", line 841, in force_type
    response = BaseResponse(*_run_wsgi_app(response, environ))
  File "C:\Python34\lib\site-packages\werkzeug\wrappers.py", line 57, in _run_wsgi_app
    return _run_wsgi_app(*args)
  File "C:\Python34\lib\site-packages\werkzeug\test.py", line 867, in run_wsgi_app
    app_iter = app(environ, start_response)
TypeError: 'Area' object is not callable
def user():
    c = Area[1]
    name = c.name
    return name