장고3 [Django] View 안에서 데이터 모델 특정 갯수만 가져오는 방법 1. 다음과 같이 뷰(View.py) 파일을 작성하세요. # 특정 앱(appName)의 데이터 모델(ModelName) 로딩 from appName.models import ModelName def function(request): # 인스턴스 생성 # 데이터 모델의 필드명('id')을 선택 # 원하는 갯수([:3] = 3개)만큼 쿼리셋 로딩 instance = ModelName.objects.all().order_by('id')[:3] # 'key':value 형태로 데이터 전달 context = { 'instance':instance, } return render(request, '~.html', context) 결과는 instance 라는 이름의 인스턴스에 3개의 쿼리셋이 담겨옵니다. 데이터를 가져.. 2019. 10. 17. [django] how to runserver stop in windows10 1. open terminal (ex : cmd) 2. enter command like this for see used port number netstat -ano 3. check port number in list 4. enter command like this for stop used port number(3600) taskkill /pid 3600 /f DONE 2019. 10. 13. [Django] 템플릿 언어 문자열 자르기 | Slice String in template "본 글은 '2019-10-07' 최초 작성되었으며, 업데이트 발생 시 글 내용 일부가 수정될 수 있음" 들어가기 Step 1. 템플릿 언어 사용하기 1.1. slice 사용하기 {{ weather.location | slice:":2" }} 나오기 ↓ 이거(공감) 눌러주면 진짜 힘남! 2019. 10. 7. 이전 1 다음