我有以下课程;(我正在使用 peewee 和 falcon)
models/Auth.py
:
from peewee import UUIDField, TextField
from models import BaseModel
class Auth(BaseModel):
app_name = TextField()
access_token = UUIDField()
models/Tweet.py
:
from peewee import TextField
from models import BaseModel
class Tweet(BaseModel):
username = TextField()
message = TextField()
models/__init__.py
:
from config import Database
from models.Auth import Auth
from models.BaseModel import BaseModel
from models.Tweet import Tweet
Database.connect()
Database.create_tables([Auth, Tweet], True)
"""
from config import Database
from models.BaseModel import BaseModel
from models.Tweet import Tweet
Database.connect()
Database.create_tables([Tweet], True)
"""
models/BaseModel.py
:
from datetime import datetime
from peewee import DateTimeField
from playhouse.signals import pre_save, Model
from config import Database
class BaseModel(Model):
created_at = DateTimeField(default=datetime.now)
updated_at = DateTimeField()
class Meta:
database = Database
@pre_save(sender=BaseModel)
def pre_save(sender, instance, created):
if created:
instance.updated_at = datetime.now()
在我运行时注释的代码段__init__.py
运行时没有错误,gunicorn --reload hyperion
但未注释的代码段会导致以下错误;
File "/Users/savaskoc/IdeaProjects/Hyperion/models/__init__.py", line 2, in <module>
from models.Auth import Auth
File "/Users/savaskoc/IdeaProjects/Hyperion/models/Auth.py", line 6, in <module>
class Auth(BaseModel):
TypeError: module.__init__() takes at most 2 arguments (3 given)
我无法弄清楚错误在哪里。Auth
和Tweet
类看起来一样...