목록dev (31)
Ssul's Blog
__init__ : 클래스 생성시 처음 호출함 class Person: def __init__(self): print(self, 'is generated') p1 = Person() #이때 __init__함수 호출 class Person: def __init__(self, name, age): print(self, 'is generated') self.name = name self.age = age p1 = Person('cis', 30) #이때 __init__함수 호출 self : 파이썬의 모든 메소드의 첫 파라미터, 클래스로 생성된 객체 a = Person('ccc', 20) b = Person('bbb', 30) print(a) print(b) #메모리상의 주소 출력. 그 주소가 self라고 보면 ..
| 상속 구조 View를 상속받아 APIView APIView를 상속받아 GenericAPIView(*Generic 테이블처리(get queryset, get object)) GenericAPIView + CreateModelMixin = CreateAPIView(C, POST) GenericAPIView + DestoryModelMixin = DestoryAPIView(D, DELETE) GenericAPIView + ListModelMixin = ListAPIView(R, GET) GenericAPIView + RetrieveModelMixin = RetrieveAPIView(R, GET) GenericAPIView + UpdateModelMixin = UpdateAPIView(U, PUT(전체-필수..
오늘 날짜를 기준으로 이번주 월요일 찾고, 이번주 쿼리셋 출력하기 #1. 오늘 날짜 기준으로 이번주 월요일 찾기 import datetime today = datetime.date.today() print(today) # 2022-10-05 오늘날짜 print(today.weekday()) #월요일의 일자 monday = today - datetime.timedelta(days=today.weekday()) print(monday) #2022-10-03 sunday = monday + datetime.timedelta(days=6) print(sunday) #2022-10-09 #2. 이번주 로그 범위로 검색해서 쿼리셋 직렬화 #로그 생성일 기준 1주일 로그 가져오기(__range) walletlogs ..
get은 객체를 반환 - 객체.id 같이 접근가능 - 검색결과 없을시: DoesNotExist - 직렬화 필요함(객체 1개 직렬화 하는 함수) filter는 쿼리셋(객체여러개)을 반환 - 쿼리셋.id 불가(*first, last의 경우 객체반환) - 검색결과 없을시: {} - 직렬화 필요함(객체 여러개 직렬화 함수) # 예시 walletlogs = self.wallet_logs.all() json_walletlogs = serializers.serialize('json', walletlogs) return ( json_walletlogs )
[혼자 작업할 때] #1. 브랜치를 만든다 $ git branch hpagemodify $ git checkout hpagemodify (*$ git checkout -b hpagemodify 한꺼번에 가능) $ git branch *hpagemodify master #2. hpage 수정 코딩하기 #3. 온라인에 브랜치 만들기(현재는 로컬에만 있는 상태) $git push --set-upstream origin hpagemodify #4. 코딩이후, 브랜치에 add, commit, push하기 $ git checkout hpagemodify (브랜치로 이동) 코딩작업!!! $ git add . $ git commit -m "hpage modify" $ git push origin hpagemodify ..
결제페이지를 구현하면서, 자바스크립트가 한번에 먹히지 않고, 새로고침을 해야 적용되는 현상 발견 해당 문제를 해결하기 위하여 $(document).ready(function(){ 를 사용했지만 실패, 해서 터보링크를 스터디 후, 아래 코드로 수정하였지만 $(document).on('turbolinks:load', function() { 여전히 똑같은 현상반복... 결국 많은 사람의 조언에 따라... 터보링크 삭제하기로!!! 삭제하는 방법 #1. Gemfile에서 turbolinks 제거 #2. application.js에서 터보링크 제거 #3. apllication.html.erb에서 , 'data-turbolinks-track': 'reload' 제거(2개있음) #4. bundle install 후 서..
medium.com/@shaircast/ruby-on-rails-on-wsl-%EC%9C%88%EB%8F%84%EC%9A%B0-10%EC%97%90%EC%84%9C-%EB%A0%88%EC%9D%BC%EC%A6%88-%EC%84%A4%EC%B9%98%ED%95%98%EA%B8%B0-9a6164df51f Ruby on Rails on WSL (윈도우 10에서 레일즈 설치하기) 서울대 멋쟁이 사자처럼 6기 여러분, 안녕하세요. medium.com 디펜던시 리스트 보완 playinlion.tistory.com/27 윈도우 10에서 Ruby on Rails 세팅하기 - WSL 0. 윈도우 10에서 WSL이 등장하며, 예전보다 윈도우 디바이스에서 Ruby on Rails를 세팅하는 작업이 수월해졌습니다. 하지만 리..

게시판에서 검색어를 입력하여 일치하는 항목만 출력하는 방법과 카테고리명을 가지고 있는 버튼을 눌러서 해당 카테고리 항목만 출력하는 방법 두개 구현 #1. 게시판에 검색어 입력해서 출력하는 방법 우선 뷰파일 코딩 검색 평소와 같은 폼을 구성하고, 폼 이름을 query로 하고, 해당 폼에 입력되는 값을 value에 저장 컨트롤러가 쿼리가 있을때와 없을때로 구분해서 받는다. def index #쿼리가 입력되었으면, 쿼리단어가 들어간 이름들은 전부 찾아 리턴 if params[:query].present? @dbs = Db.where("name LIKE ?", "%#{params[:query]}%") else @dbs = Db.all end end 사실 두번째가 한 30분정도 고생한것 같다. 우선 버튼으로 값을..
1. 저장할 폴더 최상위에서 git init실행 $ git init 2. 폴더내 모든파일을 commit 대기중으로 만들기 git add . git status //확인하면, 빨간건 아직 커밋 대기전, 녹색은 커밋되었음 3. 모든 파일 커밋해주기 git commit -m "first commit" git status //확인하면, 다 사라짐 -> 커밋완료 4. origin 이름에 git의 repository주소 저장하고, 커밋한 파일을 origin에 전송 git remote add origin https://github.com/여러분 주소 (* git remote -v 하면 저장된 저장소 주소들 나옴) git push -u origin master 5. 수정한 파일 반영 git add . git stat..
1. devise gem을 활용하여 회원가입 기능 추가 2. 회원정보 추가 app/controllers/application_controller.rb before_action :configure_permitted_parameters, if: :devise_controller? protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :phone1, :phon2, :birth, :status]) devise_parameter_sanitizer.permit(:account_update, keys: [:name, :phone1, :phon2, :birth, :status]) end 새..