본문 바로가기

Work/Python & Django

(3)
[Django]Orm 기본 일 하며 찾아본 내용들을 기록합니다. 계속 업데이트 하자!!! SELECT Get 조건에 맞는 한건의 결과만 가져오기 위해서 사용 Entry.objects.get(id=123) Filter된 결과중 한개만 가져오기 위해서 Entry.objects.latest("created_at") 지정한 필드의 날짜를 이용해서 제일 마지막에 생성된 Object를 가져 온다.. 위와 동일하게 아래와 같이 정렬된 값의 첫번째 혹은 마지막을 지정할 수 있다. Entry.objects.filter(조건).order_by("created_at").first() Entry.objects.filter(조건).order_by("created_at").last() Like 검색 1. 대소문자 구분 Column 명에 __contains..
[Python] 기본 문법 난수 발생 from random import * i = randint(1, 100) # 1부터 100 사이의 임의의 정수 print(i) f = random() # 0부터 1 사이의 임의의 float print(f) f = uniform(1.0, 36.5) # 1부터 36.5 사이의 임의의 float print(f) i = randrange(1, 101, 2) # 1부터 100 사이의 임의의 짝수 print(i) i = randrange(10) # 0부터 9 사이의 임의의 정수 print(i) string 문자열 특정 문자로 채우기 1. zfill : String의 길이 외에 0으로 채움 # 1. zfill(__length) # 기대 3 --> "000003" >>> str(3).zfill(6) '000..
[Django] Email Template 발송하기 [참고] https://gist.github.com/LowerDeez/9a8b30428a96c4b965d059925a7bd659 Django. Send mail with custom html template and context Django. Send mail with custom html template and context - order_conf.html gist.github.com https://stackoverflow.com/questions/2809547/creating-email-templates-with-django Creating email templates with Django I want to send HTML-emails, using Django templates like this: ..