brunch

매거진 백엔드

You can make anything
by writing

C.S.Lewis

by 내가 사는 세상 Dec 01. 2023

Django - 기본설정 config

settings.py, urls.py, wsgi.py

- settings import 원천

from django.conf import settings # local, prod가 알아서 구분됨




1. base.py


import os
import os.path import join


AUTH_USER_MODEL = 'accounts.User'


TIME_ZONE = "Asia/Seoul"



STATIC_URL = "/static/"

STATIC_ROOT = os.path.join(BASE_DIR, "static")


MEDIA_URL = "/media/"

MEDIA_ROOT = os.path.join(BASE_DIR, "media")




2. local.py





3. prod.py




urls.py


from django.conf import settings
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
    path('accounts/', include('allauth.urls')),
    path('api-auth/', include('rest_framework.urls')),
    path('dj-rest-auth/', include('dj_rest_auth.urls')),
]

if settings.DEBUG:
    urlpatterns += [
        static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT),
        path("__debug__/", include("debug_toolbar.urls")),
    ]

매거진의 이전글 Django - 계정(accounts)앱 - model
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari