Python/Django

[Django] Class-based views 상세 설명 사이트 클래스(class) 기반의 뷰(views) 상세 설명 사이트이다. django 공식 문서보다 훨씬 잘 정리되어 있고, 오버라이딩할 변수/함수를 찾기 쉽다. 😉장고 클래스 뷰 (class-based generic views) http://ccbv.co.uk/ Django Class-Based-View Inspector -- Classy CBV What are class-based views anyway? Django's class-based generic views provide abstract classes implementing common web development tasks. These are very powerful, and he..
[Django][Error] DRF 실행 관련 에러들 1. authenticators 에서 TypeError: 'type' object is not iterable ... 생략 ... File "/Users/jiyeon/.local/share/virtualenvs/backend-VwpUB2OP/lib/python3.7/site-packages/rest_framework/views.py", line 272, in get_authenticators return [auth() for auth in self.authentication_classes] TypeError: 'type' object is not iterable 해결방법 settings.py의 REST_FRAMEWORK 튜플이 정상적으로 입력되었는지 ..
[Python] Pythonanywhere에 배포하기 완성된 개인 프로젝트(어플리케이션)을 배포(호스팅)하는 방법은 aws, heroku 등등... 다양하며, 그 중 pythonanywhere를 통해 배포하는 방법이다. 😉 들어가기 전에... * Git에 배포하려는 프로젝트가 올라가 있어야 한다. * settings.py 파일 ALLOWED_HOSTS 부분에 ".pythonanywhere.com"이 리스트에 포함되어 있거나 "*"가 추가되어 있어야지만 접속이 가능하다. 👩‍🏫 사이트 주소 : pythonanywhere pythonanywhere는 유료이지만 제한된 계정인 beginner account는 무료이다. 먼저, create a beginner account를 눌러 계정을 만들어 준다. usern..
[Django][Error] CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. django에서 다국어 지원을 위해 django-admin의 makemessages 명령어를 사용하려는 도중 commanderror가 발생한 경우 $ django-admin makemessages --locale=ko CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. 👩‍🔧 먼저, brew를 이용해서 gettext를 설치한다. $ brew install gettext 👩‍🔧 링크 설정을 ..
[Django] Django custom template tags Django에서 제공하는 django templates의 한계를 극복, 개발자가 직접 template를 제작하여 사용할 수 있다. - custom template_tags는 반드시 앱 안의 "templatetags"폴더 안에 생성해야한다. - templatetags폴더가 포함된 앱은 반드시 INSTALLED_APPS 에 선언되어 있어야 한다. - django templates에 custom templates를 추가한 경우 서버를 재시작해야 정상적으로 적용된다. 💁‍ filter django templates 에서 |를 이용해서 사용한다. @register.filter name: 필터 이름 is_safe needs_autoescape exp..
django-dotenv 프로젝트폴더에 .env 라는 파일을 만든 후 파일 안에 수 많은 variable(변수)들을 정의한 후 사용중인 프로세스 즉, 코드에서 .env 파일로부터 변수를 읽어 사용할 수 있다. 이렇게 하면 보호가 필요한 데이터베이스나 메일서버 아이디/비밀번호 등을 환경변수(enviroment)에 정의해 두기 git 같은 곳에 공개되지 않도록 숨길 수 있게 된다. 👉 https://github.com/jpadilla/django-dotenv 👉 django-dotenv 설치 $ pip install django-dotenv 👉 django-dotenv 사용 프로젝트 폴더 내에 .env 파일 생성 후 보호가 필요한 변수 정의 예) mysql 데이터베이스 계정 정보 저장MYSQL_USERNAM..
S0PH1A
'Python/Django' 카테고리의 글 목록