DJango 시작하기1

행행·2022년 5월 14일
post-thumbnail

기본세팅

1) vs코드 열기, 가상화면 python -m venv venv

2) 가상환경 실행 source venv/Scripts/activate

3) 인터프리터 설정

4) pip list 로 확인

5) pip install -r requirements.txt

6) 장고 설치 pip install django==3.2.12

7) django-admin startproject '프로젝트 이름'

8) python manage.py startapp '앱 이름'

9) INSTALLED_APPS 에 '앱 이름' 추가

10) URLS 작성

11) 프로젝트에서

#project/urls.py
#아티클즈의 urls은 아티클즈가 관리함!

from django.contrib import admin
from django.urls import path,include

    urlpatterns = [
    ...
    path('articles/', include('articles.urls')),
	...
]

12) '앱'에 urls.py 설정해주기

#articles/urls.py
from django.urls import path
from . import views



app_name = 'articles'
urlpatterns = [
    path('', views.index, name='index'),
    path('index/', views.index, name='index'),
    
    
    
    
    ........
    
]

13) appview 함수 설정

#articles/views.py
def index(request):
    context={
    }
    return render(request, 'articles/index.html', context)
profile
성장하려고 분투 중인 개발자

0개의 댓글