본문 바로가기

Python

(52)
[Error solved][Django+PostgreSQL] Django model 변경 후 기존 DB table 변경하기 / 오류: video_video.author_id 칼럼 없음 오류 발생 [Django] django model과 User 연결시키기 / 해당 model을 인스턴스화한 user만 model을 delete할 수 있게 하기 Django model의 field값 추가 후, migration까지 새로 했음에도 다음과 같은 오류가 났다 오류 내용 해결 방법 migrations 디렉토리를 로컬에서 삭제해도, 실제 DB에 django_migrations라는 테이블로 저장되어 있다는 것을 알게 됐다. pgAdmin4을 실행하고, django_migrations 테이블을 확인해해보니, migrate 명령이 반영이 되지 않은 것을 볼 수 있다. 그래서, 강제로 로컬 프로젝트 앱 폴더 내의 migration 파일을 강제로 DB에 푸시할 방법을 찾았다. How To Force Reset..
[Django] django model과 User 연결시키기 / 해당 model을 인스턴스화한 user만 model을 delete할 수 있게 하기 참고 Referencing the User model 실습 저장소 https://github.com/JisunParkRea/djangotube_tutorial JisunParkRea/djangotube_tutorial Simple video service which can upload youtube videos using django - JisunParkRea/djangotube_tutorial github.com 구현하고자 하는 기능 해당 video를 만든 사용자만 그 비디오를 삭제할 수 있게 하기 video_detail 페이지로 들어가면 해당 video를 만든 사용자에게만 delete 버튼이 보여지게 하기 models.py Video model에 author field를 추가하여, 자동적으로 user..
[python] 파이썬 내장함수: zip(), reversed() 참고 Programiz: Python zip() 점프 투 파이썬: 내장함수 Python documentation: Built-in Functions zip() iterables를 하나의 tuple로 합친 후 리턴 예제 number_list = [1, 2, 3] str_list = ['one', 'two', 'three'] temp = list(zip(number_list, str_list)) print(temp) # [(1, 'one'), (2, 'two'), (3, 'three')] * 리스트로 만들기 위해서는 list(zip())이 필요하다! reversed() reverse iterator을 리턴 예제 # for string seq_string = 'Python' print(list(reversed..
[Two Scoops of Django] 2. The Optimal Django Environment Setup * 해당 포스트는 'Two Scoops of Django: Best Practices for Django 1.8 Book by Audrey Roy Greenfeld and Daniel Roy Greenfeld'를 공부하며 적은 기록입니다. 오늘 읽은 부분 2. The Optimal Django Environment Setup 전 하위 목차 기억해야할 부분 2.1 같은 DB 엔진을 사용하자 local이나 production에서도 production 데이터의 똑같은 copy를 local에서 검증할 수가 없다 DB가 다르면 field type이나 constraints도 다르다. SQLite3은 dynamic하고 weak typing Django ORM이 내가 쓴 코드가 SQLite3와 more strongly..
[Django Authentication] 회원가입, 로그인, 로그아웃 기능 구현 / 일일이 다 구현해보자 https://github.com/JisunParkRea/djangotube_tutorial JisunParkRea/djangotube_tutorial Simple video service which can upload youtube videos using django - JisunParkRea/djangotube_tutorial github.com 참고 초보몽키의 개발공부로그 Using the Django authentication system Django Girls Tutorial: Extensions 구현하고자 하는 기능 해당 포스트에서는 장고의 내장된 인증 기능 없이 view, urls 등을 일일이 다 구현해보았다. 회원가입 username, email, password로 가입 회원가입 시 가입 ..
[Django + PostgreSQL] PostgreSQL 설치 후 Django와 연동하기 / 기존 프로젝트 수정 PostgreSQL 설치 https://www.postgresqltutorial.com/install-postgresql/ Install PostgreSQL www.postgresqltutorial.com [Tip] psql: 오류: 서버 접속 실패: 치명적오류: 사용자 "..."의 password 인증을 실패했습니다 만약 이와 같은 오류가 발생한다면... Username을 그냥 default인 postgres로 두고 진행하고, password에는 처음 설치할 때 지정한 암호와 동일하게 입력하자 Django에 PostgreSQL 연동하기 https://www.enterprisedb.com/postgres-tutorials/how-use-postgresql-django How to use PostgreSQ..
[Django 유튜브 동영상 업로드 서비스] 나의 첫번째 DjangoTube 프로젝트(계속 업데이트 중...2020/04/28) 실습 Github 주소 https://github.com/JisunParkRea/my_djangotube JisunParkRea/my_djangotube Simple video service which can upload youtube videos using django - JisunParkRea/my_djangotube github.com Heroku 배포 주소 -> http://djangotube.herokuapp.com/video/ 수정한 부분 - 나의 첫번째 장고튜브 프로젝트[참고] 기반으로 계속 수정중 - templates 파일들 첫문장인 {% load staticfiles %} 삭제 - reverse()를 삭제하고 redirect()만 사용 - urls 설정에 레거시한 표현방법 수정 예) r'..
[Two Scoops of Django] 1. Coding Style * 해당 포스트는 'Two Scoops of Django: Best Practices for Django 1.8 Book by Audrey Roy Greenfeld and Daniel Roy Greenfeld'를 공부하며 적은 기록입니다. 오늘 읽은 부분 1. Coding Style 전 하위 목차 기억해야할 부분 1.1 The Importance of Making Your Code Readable variable name을 생략하지 말자: 모두가 해석하기 쉽게 1.2 PEP8 PEP8: official style guide for Python 팁! Flake8(command-line tool for checking coding quality) 한줄에 79-character만 쓰도록 하자 1.3 The W..