🐛 Support apps without any models
This commit is contained in:
parent
e1f5ce589c
commit
3e15aa7722
1 changed files with 5 additions and 2 deletions
|
|
@ -154,7 +154,10 @@ class Project:
|
|||
tortoise_cfg = self.build_tortoise_config(db_url=db_url)
|
||||
|
||||
# Prevent leaking other app's models to Aerich.
|
||||
if app_label in tortoise_cfg["apps"].keys():
|
||||
tortoise_cfg["apps"] = {app_label: tortoise_cfg["apps"][app_label]}
|
||||
else:
|
||||
tortoise_cfg["apps"] = {app_label: {"default_connection": "default", "models": []}}
|
||||
|
||||
# Append aerich.models to the models list of the target app only
|
||||
tortoise_cfg["apps"][app_label]["models"].append("aerich.models")
|
||||
|
|
@ -403,7 +406,7 @@ class App:
|
|||
"""
|
||||
return {
|
||||
"models": [
|
||||
f"{self.name}.{m.__name__}" for m in self.models[f"{self.name}.models"]
|
||||
f"{self.name}.{m.__name__}" for m in self._models[f"{self.name}.models"]
|
||||
],
|
||||
"middlewares": self.__serialize_middleware(),
|
||||
"routes": self.__serialize_router(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue