diff --git a/demo/demo/settings.py b/demo/demo/settings.py index 26ff682..e227523 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -14,7 +14,7 @@ from typing import Dict, List from pydantic import Field -from pydantic.fields import Undefined +from pydantic.v1.fields import Undefined from pydantic_settings import BaseSettings, SettingsConfigDict from pydjantic import BaseDBConfig, to_django diff --git a/pydjantic/pydjantic.py b/pydjantic/pydjantic.py index aca40d6..0f17e1f 100644 --- a/pydjantic/pydjantic.py +++ b/pydjantic/pydjantic.py @@ -30,12 +30,11 @@ def format_config_from_dsn(cls, value: Any, info: ValidationInfo): if info.field_name: extra = cls.model_fields[info.field_name].json_schema_extra - if extra: + if isinstance(extra, dict): for kwarg in known_dj_database_url_kwargs: - if isinstance(extra, dict): - field_extra = extra.get(kwarg) - if field_extra is not None: - kwargs[kwarg] = field_extra + field_extra = extra.get(kwarg) + if field_extra is not None: + kwargs[kwarg] = field_extra return dj_database_url.parse(str(value), **kwargs)