0826 SeSAC(새싹) 3기 10일차

장고에서 토큰을 발행할 때는 "쿠키"라는 브라우저의 기능을 사용한다.

그런데 웹브라우저설정에 "쿠키"를 막아놨으면 사용을 못하므로 장고의 폼은 작동하지않게 된다.


폼 태그

특정값으로 변할 때 그거와 관련된것만 보여줄 수 있다?
function select_gu(obj) {
if (obj.value == "서울특별시")
#inputCounty 아이디 값을 가진 옵션의 value값이 출력
document.getElenmentById("inputCounty").value;
#console.log("서울에 해당하는 구를 표시해!");
else if (obj.value == "경기도") console.log("경기도에 해당하는 구를 표시해!");
else console.log("그런 시는 없어!");

document.getElenmentById("inputCounty").value;

}

this -> 자기 자신

싹!

function select_gu(obj) {
if (obj.value == "서울특별시")
#싹!이 inputCounty 아이디 값을 가진 옵션의 value값으로 변한다.
document.getElementById("ssac_label").innerHTML = document.getElenmentById("inputCounty").value;

document.getElementById("inputCounty").innerHTML = 강남구강북구
}

----------------------------------------------- document.getElementById( "id" ) innerHTML value

등을 사용하여 동적 select 를 구현하여라!

--> 이거 혼자 해보기


코드펜?
-> 이런 것도 잇구나..


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

urlpatterns = [
    path('ok', views.hello ),
    path('send', views.send ),
    path('receive', views.rec ),
    path('novel/<int:chapter>/<str:cha1>/<str:cha2>', views.novel )
]
#views.py
from django.shortcuts import render

# Create your views here.

def hello( req ) : 
    a = 5
    b = 8
    c = a + b

    return render( req, 'a.html', {'parameter1':c, 'parameter2':'육은별'})

def send( req ) :
    return render( req, 'b.html' )

def rec( req ) :
    return render ( req, 'd.html', { 'info1':req.POST.get('name'), 'info2':req.POST .get('address') } )

def novel( req, chapter, cha1, cha2 ) :
    return render ( req, 'novel.html', { 'chapter':chapter, 'cha1':cha1, 'cha2':cha2 } )
#novel.html
이 소설은 {{ chapter }}권입니다. <br>
주인공 이름은 {{ cha1 }} 이고 <br>
악역 이름은 {{ cha2 }} 입니다.

#views.py
from django.shortcuts import render

# Create your views here.

def hello( req ) : 
    a = 5
    b = 8
    c = a + b

    return render( req, 'a.html', {'parameter1':c, 'parameter2':'육은별'})

def send( req ) :
    return render( req, 'b.html' )

def rec( req ) :
    return render ( req, 'd.html', { 'info1':req.POST.get('name'), 'info2':req.POST .get('address') } )

#cha1 = '육은별' 이렇게 디폴트값을 줄 수 있다.
def novel( req, chapter, cha1 = '육은별', cha2 ) :
    return render ( req, 'novel.html', { 'chapter':chapter, 'cha1':cha1, 'cha2':cha2 } )

static 파일 불러오기

static(정적) -> 이미지 파일이 대표적

파일질라에서 앱 폴더에 static 폴더를 만들고 그 안에 이미지 파일을 업로드 해줘야됨

{% load static %} #이걸 꼭 써줘야됨
    
<img src="{% static 'cat.jpg'%}">

{% load static %}
-> static 파일을 다 수집해옴


validation 유효성 검사

정규식 regex

/[a-z]{2,4}/
-> a부터 z까지 2개에서 4개까지만 허용

/^[a-z]{2,4}@[a-z]./
-> .은 임의의 글자 하나를 의미
*은 임의의 글자 0개 이상

\ -> 이스케이프 문자 : 그 바로 뒤에 나오는 문자는 문자 그대로 받아들이기로 한다.

. -> .이 그대로 출력

alert("하\"동\"화"); -> 하"동"화 이렇게 출력된다.

() -> 복수개의 식을 하나로 묶을 수 있다.

https://regex101.com/

https://blog.naver.com/juliet_4/222404045587

\w = [a-zA-Z0-9_] -> 63개문자 (대소문자+숫자+_) 일치

[\W-] -> - 추가

[\w-]+ -> 임의의 글자 한개 이상

/^[\w]{4,}@[\w]+(.[\w-]+){1,3}$


-> 이렇게하면 필수로 입력해야 됨 -> 패턴을 통해 필터링을 할 수 있다.

좋은 웹페이지 즐겨찾기