파이썬 django 연산자2 파이썬 Django Operator-1 파이썬 Django 논리 연산자(Operator) : and 둘 이상의 조건이 참인지 확인한다. 2개의 논리값이 모두 참일 때 참 결과값을 반환한다. 둘 중에 하나의 논리값이 거짓일 경우에는 거짓을 반환한다. template.html {% if greeting == 1 and day == "Friday" %} Hello Weekend! {% endif %} In views.py you can see what the variables look like. views.py from django.http import HttpResponse from django.template import loader def testing(request): template = loader.get_template('template.. 2024. 3. 5. 파이썬 django if tag 파이썬 django if 문 if 문은 변수를 평가하고 값이 참이면 코드 블록을 실행한다. templates.html {% if greeting == 1 %} Hello {% endif %} In views.py you can see what the greeting variable looks like. views.py from django.http import HttpResponse from django.template import loader def testing(request): template = loader.get_template('template.html') context = { 'greeting': 1, } return HttpResponse(template.render(context, req.. 2024. 3. 4. 이전 1 다음