-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pydantic serializer warnings, such as "Expected multi-host-url
but got dict
- serialized value may not be as expected"
#31
Comments
Hey @earshinov 👋🏻 |
Hey @erhosen, sure! Tests above are run with
I observe the same errors in my project, running
|
Hi there 👋🏻 This may be a pragmatic approach and may not fix the root cause, but it will get rid of the warnings: Just set the type of your DatabaseConfig to class DatabaseSettings(BaseDBConfig):
"""https://docs.djangoproject.com/en/dev/ref/settings/#databases"""
default: str | dict[str, Any] = Field(
default=str(f"sqlite:///{BASE_DIR}/db.sqlite3"),
validation_alias="DATABASE_URL",
conn_max_age=0,
ssl_require=False,
)
model_config = SettingsConfigDict(env_file=BASE_DIR / ".env") (Tested with Python 3.10.12, Django 5.0.6, pydjantic 1.1.4) I'm not sure if this might be confusing, but if you want I can do a quick pr to add this to the tests and demo. |
Thanks @worldworm, it would be nice to get rid of the warning! |
Even when running tests:
Seems to come from database configuration, e.g. (in
test_dsn_and_exact_config
):Applications still run, however:
-Werror
python interpreter flagThe text was updated successfully, but these errors were encountered: