개발 일지

TIL(24.04.19)

만식 2024. 4. 19. 03:53

출처 : https://online.spartacodingclub.kr/enrolleds/66134275f7c0c6ab299bed92/rounds/661341fdd9c7e6af9aaf398d/roadmap

 

스파르타코딩클럽

스파르타코딩클럽 | 올해의 브랜드 대상 1위 왕초보를 위한 온라인 코딩강의

online.spartacodingclub.kr

오늘의 TIL

.

.

.

Django URLs

 

path("users/<str:username>/", views.profile
#urls.py

 

def profile(request):
		return render(request, "profile.html")
        #views.py

 

path("users/<str:username>/", views.profile),
# urls.py 정답코드

 

def profile(request, username):
		context = {
				"username" : username,
		}
		return render(request, "profile.html", context)
#views.py 정답코드

 

{% extends "base.html" %}

{% block content %}
		<h1>{{ username }}의 프로필 페이지</h1>
		
		<div>
			<h2>username : {{ username }}</h2>
		</div>
		
		<a href="/index/">홈으로 돌아가기</a>
		
{% endblock content %}
#profile.html 정답코드

 

Dispatcher란 들어온 요청을 어디로 보내서 처리할지 정하는 곳

 

/란?

https://www.mycooooolsite.com/

https://www.mycooooolsite.com

위에 두 링크는 다른 것!
- 첫 번째 링크 : 디렉터리

- 두 번째 링크 : 파일

> 원래 이런 의미를 가지고 있는데, 오늘날에는 같은 것으로 인식하는 경우도 많음

 

트레일링 슬래시(Trailing slash)

- 개념 자체는 URL 뒤에 붙는 슬래시

- but, 자꾸 회자되는 이유 > 컴퓨터들 사이에서는 저 두 개는 다른 것이기 때문임