mirror of
https://github.com/kevin-DL/full-stack-fastapi-postgresql.git
synced 2026-01-13 02:25:26 +00:00
✨ Use Pydantic BaseSettings for config settings (#87)
* Use Pydantic BaseSettings for config settings * Update fastapi dep to >=0.47.0 and email_validator to email-validator * Fix deprecation warning for Pydantic >=1.0 * Properly support old-format comma separated strings for BACKEND_CORS_ORIGINS Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from app import crud
|
||||
from app.core import config
|
||||
from app.core.config import settings
|
||||
from app.schemas.user import UserCreate
|
||||
|
||||
# make sure all SQL Alchemy models are imported before initializing DB
|
||||
@@ -14,11 +14,11 @@ def init_db(db_session):
|
||||
# the tables un-commenting the next line
|
||||
# Base.metadata.create_all(bind=engine)
|
||||
|
||||
user = crud.user.get_by_email(db_session, email=config.FIRST_SUPERUSER)
|
||||
user = crud.user.get_by_email(db_session, email=settings.FIRST_SUPERUSER)
|
||||
if not user:
|
||||
user_in = UserCreate(
|
||||
email=config.FIRST_SUPERUSER,
|
||||
password=config.FIRST_SUPERUSER_PASSWORD,
|
||||
email=settings.FIRST_SUPERUSER,
|
||||
password=settings.FIRST_SUPERUSER_PASSWORD,
|
||||
is_superuser=True,
|
||||
)
|
||||
user = crud.user.create(db_session, obj_in=user_in)
|
||||
|
||||
Reference in New Issue
Block a user