-
Delete
from django.shortcuts import render,HttpResponse,redirect from django.views.decorators.csrf import csrf_exempt nextId = 4 topics = [ {'id':1, 'title':'routing', 'body':'Routing is ..'}, {'id':2, 'title':'view', 'body':'View is ..'}, {'id':3, 'title':'Model', 'body':'Model is ..'}, ] def HTMLTemplate(articleTag, id=None): global topics contextUI = '' if id != None : contextUI = f''' ''' ol = '' f..
파이썬/Django
2022. 9. 18.
-
홈페이지에 읽기 기능 구현
from django.shortcuts import render,HttpResponse import random topics = [ {'id':1, 'title':'routing', 'body':'Routing is ..'}, {'id':2, 'title':'view', 'body':'View is ..'}, {'id':3, 'title':'Model', 'body':'Model is ..'}, ] # 글을 딕셔너리에 담고, 이 값들을 모아 topics라는 리스트에 넣어 줍니다. def index(request): global topics # topics 변수를 사용하기 위해 전역 변수로 지정 ol = '' #ol이라는 변수를 만든다. for topic in topics: ol += f'{topic["t..
파이썬/Django
2022. 9. 18.