Skip to content

Commit

Permalink
Fix: Undefined import in demo app.
Browse files Browse the repository at this point in the history
Also improved format_config_from_dsn() readability
  • Loading branch information
Andrey Lepekhin committed Nov 26, 2023
1 parent b6d3a5a commit 05ea366
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions pydjantic/pydjantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 05ea366

Please sign in to comment.