[Question] Unclear docs - how to use with settings as a package
1oglop1 opened this issue · comments
The very first sentence says Very much a work in progress, but reads the standard DJANGO_SETTINGS_MODULE environment variable
in my current layout, I have settings
as a package where all environments inherit from base.py
and then environment-specific values, I'm not sure how could I use this project with the layout.
├── __init__.py
├── base.py
├── local.py
├── production.py
├── staging.py
└── test.py
Here is what I'd do:
base.py
from pydantic_settings.settings import PydanticSettings
class MyBase(PydanticSettings)
....
local.py
from .base import MyBase
class MyLocal(MyBase):
....
then I assume that content of asgi.py
would call the correct file based on DJANGO_SETTINGS_MODULE
.
from django.core.asgi import get_asgi_application
from pydantic_settings import SetUp
SetUp().configure()
application = get_asgi_application()
Is that correct?
Thank you!
It's been a while since I've set up a new project, but this is the specific use-case I built this for (based on older projects of mine using django-configurations). In your specific case, DJANGO_SETTINGS_MODULE should be set to something like my_project.settings.local.MyLocal
.