postgres 작동 안될 때 list-dependencies 확인하기 가끔 postgres가 서버에서 정상적으로 작동하지 않을 때 문제를 찾기 위해 로그를 뒤지거나 systemctl status postgres로 상태를 보는데, 그것보다 훨씬 쉽고 직관적으로 작동되는 모든 postgres list-dependencies를 확인할 수 있는 명령어가 있어서 남겨놓는다.sudo systemctl list-dependencies postgresql backend/sql (postgres) 2017.11.15
AWS IAM으로 사용자 만들기 AWS를 사용하다 보면 s3 등 사용자 권한이 필요한 경우가 있다. 이런 경우 iam을 통해 유저를 만들고 aws access key, secret key를 발급 받아야 한다.IAM 유저 생성user 만들기aws 콘솔에서 IAM 서비스로 이동한다. 기존에 User가 없다면 user를 만들어야 한다. user 창으로 들어가 Add user를 한 뒤 username을 입력해 주고, access type을 지정해 준다. AWS 콘솔용 유저라면 AWS management console access를, cli를 사용하려면 Programmatic access에 체크를 해 준다.(group이 없다면) group 생성해주기user를 만들 때 해당 유저의 그룹을 생성 해 주어야 하는데, 처음 만드는 경우라면 그룹이 없을.. tools/aws 2017.11.14
jekyll 오류 발생시 해결법 bundle exec jekyll serve 오류 발생Bundler could not find compatible versions for gem "jekyll" 오류가 발생… 검색 후 다음과 같이 해결Gemfile, Gemfile.lock을 삭제Gemfile에 다음을 입력source 'https://rubygems.org' gem 'github-pages' bundle install tools/jekyll blog 2017.11.13
Change django migration file name after migrate django에서 migration 파일을 관리하다 보면, 서로 다른 곳에서 makemigration 명령어를 진행해 서로 같은 내용의 migration 파일이 이름만 다른 경우가 발생한다. (물론 한 곳에서만 makemigration 하는 것이 가장 좋은 방법인것 같다.)이런 경우에 git을 통해 파일 명을 맞춰버리면 migrate 을 했을 경우에 이름이 다른 파일을 전혀 다른 migration 파일로 인식하기 때문에 동일한 내용을 두 번 migrate하여 대개 already exist 에러가 발생한다.다양한 방법으로 해결이 가능하지만, 가장 편리한 방법은 역시 --fake migrate 방법이다.1. 파일명 변경이름이 다른 파일의 파일명 (대개는 시간이 다른 경우가 많다)을 변경해준다. (안에 내용에도.. backend/django 2017.11.11
django project에 cloudfront(s3) 연결하기 0. aws s3 생성 및 cloudfront 연동이 부분은 permission, property 등 생각보다 설정해야 할 것이 많으므로 다른 포스팅에서 따로 다룰 예정이다.1. 초기 라이브러리 설치1. Install django-storage공식문서를 참고해서 django-storage 를 설치설치 이후에는 settings.py에 추가해준다.INSTALLED_APPS = ( ... 'storages', ... ) 2. Install boto3boto 공식 문서를 참고하여 설치 (pip install boto3)2. MediaStorage module 추가하기S3Boto3Storage를 상속받는 MediaStorage를 만들어야한다. 위치는 settings.py가 있는 디렉토리나, common app(u.. backend/django 2017.11.09
django get site-url in template project를 진행시 한 코드를 여러 url에 물리고 싶을 때가 있다. 그럴 때 javascript 내에서 절대경로로 하드코딩하게 되면 추후에 모든 url을 다 수정해야 하는 일이 발생하기 때문에 모든 url domain을 물리는 방법을 찾아보았다.request.META.HTTP_HOST 사용하기request.META가 가지고 있는 여러 정보들 중 HTTP_HOST를 사용하면 현재 request가 접속중인 HOST, 즉 절대경로를 던져준다. 이걸 써도 무방하지만 request를 받아야만 해당 site url을 반환하기 때문에 다른 방법을 사용하였따.Template context_processor 사용하기만약 settings.py를 local, production, aws 등 나누어 관리한다면 다음 방법.. backend/django 2017.11.07
django allauth로 Linkedin 로그인 구현하기 [이전 포스트]의 allauth 사용법을 읽고 allauth 설치하고, INSTALLED_APP에 linked-in을 추가를 완료한 후 이 포스트를 따라해야함1. 앱 만들기linkedin developer로 들어가서 새로운 앱을 만든다.회사명, 이름, 사용할 URL 등을 적은 후 만들어진 앱의 클라이언트 ID, 비밀 키를 django admin의 social application에 추가해준다.2. OAuth 2.0 에 인증된 리다이렉트 URL 추가하기redirect url로 http://localhost:8000/accounts/linkedin_oauth2/login/callback/를 추가3. settingsSOCIALACCOUNT_PROVIDERS = { 'linkedin': { 'SCOPE': [ .. backend/django 2017.11.06
django-hitcounts: 페이지 view를 쉽게 이용하자 설치법여느때와 같이 pip를 이용해 설치해주자.pip install django-hitcount Installed app에 넣는것을 까먹으면 안된다# settings.py INSTALLED_APPS = ( ... 'hitcount' ) DetailView, Model에 추가하기CBV (DetailView)를 사용해서 detail page를 만들어 놓았다면, 아주 쉽게 hit 수를 카운팅할 수 있다. (만약 fbv로 구현이 되어있다면 이번 기회에 CBV를 사용해보자. 좋다.)# models.py from django.db import models from hitcount.models import HitCountMixin # 다음과 같이 HitCountMixin을 상속받아주자 class MyModel(mod.. backend/django 2017.11.04
allauth facebook 로그인 세팅 (삽질은 그만..) django facebook login with allauthuseful sites-django allauth documentbasic usageinstall allauth pip install django-allauthedit settings.py# Specify the context processors as follows: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ # Already defined Django-related contexts here # `allauth` needs this.. backend/django 2017.10.23
postgres basic usage-about Role PostgreSQL managing RoleChecking Role# accessing with postgres user sudo -u postgres psql # check user \du Creating Role# create role in command-line # answer questions after this command sudo -u postgres createuser --interactive # create role in psql prompt # you can add roles in myrole sudo -u postgres psql CREATE ROLE myrole; Alter Role to userthere’s many role in postgres- LOGIN, CREATEDB, C.. backend/sql (postgres) 2017.10.22