개발 패턴 | 앱 시작

HeeJune KIM·2023년 4월 2일
0

Django_Pinterest

목록 보기
2/13

MVC -> MTV? MVT?

Model View Controller

Model | View | Template

Model > django <-> Database | 모델을 설정해주면, 장고가 CRUD를 실행해준다.
View > 장고에서 계산하는 부분을 대부분 담당한다. Request 처리 Response 발송
Template > JS, CSS, HTML | User Interface


첫 앱 시작, 그리고 기본적 View 만들기

python manage.py startapp accountapp

pragmatic/urls.py
	```
    path('account/', include('accountapp.urls')),
    	# accountapp.urls 파일에 접근하기 위해서 서버 주소인 8000/뒤에 account를 사용한다. 
    ```
accountapp/urls.py
	``` 
    app_name = "accountapp" 
    	# accountapp:hello_world로 요청하면 8000포트로 접근해서 정확한 주소를 불런주는 함수가 존재한다. 
        
    urlpatterns = {
	    path('hello_world/', hello_world, name='hello_world'),
        }
    # views.py의 hello_world()를 호출한다. 
    ```
    

http://127.0.0.1:8000/account/hello_world/


Q

  1. accountapp/urls.py

    path('hello_world/', hello_world),
    path('hello_world/', hello_world, name='hello_world'),
    똑같이 작동하는 이유?

0개의 댓글

관련 채용 정보