Python peewee:对象没有属性_meta
我正在使用Python 3.3 32位在Windows上工作。我已经安装了peewee,想试试它的一些功能。我从Peewee Quickstart()开始 我的代码如下所示:Python peewee:对象没有属性_meta,python,python-3.x,attributeerror,peewee,Python,Python 3.x,Attributeerror,Peewee,我正在使用Python 3.3 32位在Windows上工作。我已经安装了peewee,想试试它的一些功能。我从Peewee Quickstart()开始 我的代码如下所示: from peewee import * db = SqliteDatabase('people.db') class Person(Model): name = CharField() birthday = DateField() is_relative = BooleanField()
from peewee import *
db = SqliteDatabase('people.db')
class Person(Model):
name = CharField()
birthday = DateField()
is_relative = BooleanField()
class Meta:
database = db
class Pet(Model):
owner = ForeignKeyField(Person, related_name = "pets")
name = CharField()
animal_type = CharField()
class Meta:
database = db
Person.create_table()
Pet.create_table()
我得到一个错误:
File "<stdin>", line 1, in <module>
File "<string>", line 21, in <module>
File "C:\Python33\lib\site-packages\peewee.py", line 2094, in create_table
db = cls._meta.database
AttributeError: type object 'Person' has no attribute '_meta'
文件“”,第1行,在
文件“”,第21行,在
文件“C:\Python33\lib\site packages\peewee.py”,第2094行,在create_表中
db=cls.\u元数据库
AttributeError:类型对象“Person”没有属性“\u meta”
我安装的peewee有什么问题吗?如何解决此问题?Peewee与Python 3不兼容;目前它只适用于Python2
你看到的错误就是这样的结果;Model
类使用Python2技术定义了一个元类,这在Python3中有所改变
2013-04-02发布的更新增加了Python 3的兼容性。该包现在支持Python 2.6、2.7和3.2及更高版本