본문 바로가기

Python/Django

(33)
[Django] Hardcoded URL 제거 / Namespacing URL names 출처 Django Documentation -Removing hardcoded URLs in templates Removing hardcoded URLs in templates Hardcoded URLs 예시 {{ question.question_text }} Hardcoded URLs 제거 {% url %} template tag {{ question.question_text }} polls.urls 모듈 # ... path('/', views.detail, name='detail'), Namespacing URL names polls 앱 외에 여러 앱들이 있는 경우 app_name을 명시해줌으로써 url name의 중복을 방지할 수 있다. polls/urls.py from django.urls imp..
[Django ORM] Django QuerySet으로 간단한 검색 기능 구현하기 참고 Django Documentation | QuerySet API reference Django Documentation | Making queries Django Documentation | Search Stackoverflow - Default value of request.GET.get() 초보몽키의 개발공부로그- Queryset을 활용한 아주 간단한 필터검색 구현 실습 저장소 https://github.com/JisunParkRea/djangotube_tutorial JisunParkRea/djangotube_tutorial Simple video service which can upload youtube videos using django - JisunParkRea/djangotube_tut..
[Error solved][Django+Ajax] method object is not JSON serializable 에러 에러 내용 C:\Users\jisun\dev\python\django\djangogirls_video\video\views.py changed, reloading. Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). April 22, 2020 - 19:55:04 Django version 3.0.5, using settings 'djangotube.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [22/Apr/2020 1..
[Django+Ajax/jQuery] '좋아요(likes)' 기능 구현하기 / 전체 웹페이지 새로고침 없이 좋아요 개수 업데이트하기 참고 초보몽키의 개발공부로그 Many-to-many relationships stackoverflow: My own likes button 실습 저장소 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에 '좋아요'를 누를 수 있게 하기 ajax를 사용하여 웹페이지 새로고침 없이 좋아요 개수를 비동기적으로 업데이트하기 models.py Video는 여러 user로부..
[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..
[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..