[Python] 순열과 조합 하나의 리스트에서 모든 조합을 계산하는 방법 1. 순열 itertools.permutations(iterable[, r]) https://www.hackerrank.com/challenges/itertools-permutations/problem iterable: iterable한 값 r: 몇개 씩 묶을 것인지, (미 입력 -> iterable 전체 길이) >>> from itertools import permutations >>> print list(permutations(['1','2','3'])) [('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '..
전체
[Django][fancytree] ajax로 서버에서 데이터 불러오기 사용 언어 Django 1.11.22 Python 2.7 ### 먼저, Fancytree에 ajax 로 서버에서 데이터를 갖고 올 수 있도록 source에 함수를 추가해 준다. source may be callback that returns one of the above data formats. source: function(event, data){ return [{title: "node1", ...}, ...]; } [참고] https://github.com/mar10/fancytree/wiki/TutorialLoadData#use-a-callback url과 type은 자신에게 맞게 변경해 준다. 여기서 async: false를 ..
[Django][React] Django와 React 설정하기 이 글은 http://v1k45.com/blog/modern-django-part-1-setting-up-django-and-react/ 를 번역한 글입니다. - 사용 언어 Django 1.11.22 Python 2.7 ReactJS ^16.8.6 1. Virtualenv 및 Django 설치 backend폴더 생성 후 virtualenv 설치 및 활성화$ mkdir backend $ cd backend $ virtualenv venv $ source venv/bin/activate virtualenv에서 django 설치 한 후 backend프로젝트 생성(venv) $ pip install django (venv) $ django-admin..
[Django] Django Rest API 특정 필드 제외하고 검색하기 Django rest api를 통해서 검색(GET)할 때, 매번 특정 필드를 제외하고 검색한 결과를 반환하려고 했다. 그동안 Rest api가 아닌 백엔드에서 Models 검색 시, defer를 이용해서 특정 필드를 제외했었다. 모델.objects.defer('필드명') # ex) User.objects.defer('age') API 구축하면서 아래와 같이 그대로 views.py에 적용해 보았지만 원하는 결과를 얻지 못했었다. from rest_framework import viewsets from .serializers import UserSerializer from .models import User class UserViewS..
[CSS][Bootstrap] Spinner 화면 중앙 위치하도록 설정하는 방법 Bootstrap4 - spinners spinner, 즉 loading 표시를 화면 가운데(중앙)에 위치하도록 하기 위에서는 아래와 같이 css에 추가해주면 된다. .spinner { display: block; position: fixed; z-index: 1031; top: calc( 50% - ( ...px / 2) ); /* where ... is the element's height */ right: calc( 50% - ( ...px / 2) ); /* where ... is the element's width */ } top과 right의 ... 은 각자 자신에게 맞는 요소 크기를 입력해 주면 된..
[JavaScript] TreeView 사용하기 (fancytree) - 5 Drag N Drop 이전 글 : [JavaScript] TreeView 사용하기 (fancytree) - 4 context menu 드래그앤드롭(DragNDrop)기능을 사용하기 위해서는 dnd5모듈을 추가해야한다. dnd5 모듈을 이용해서 기본적인 기능은 가능하지만, 드래그앤 드롭시 목적지 폴더에 내가 옮기려는 파일과 이름이 같은 파일이 존재할 경우 예외처리를 추가하고자 한다. dnd5의 이벤트는 다음과 같다. dragStart : 드래그 이벤트 시작시 (마우스 누름) dragDrag : 드래그 이벤트 중 dragEnd : 드래그 이벤트 끝남 dragEnter : 드래그 이벤트 중 "over", "before, "after"..