Backend/Django

    django 16. Decorator를 이용한 코드 간소화

    Decorator 파이썬(Python)에서 제공하는 기능 함수의 앞, 뒤로 붙어 실제 함수를 꾸며주는 기능 사용자가 코드 구현하기 편하도록 제공 장고에서도 Django Decorator를 제공 해주고 있는데 코드를 간소화 시켜주어 가독성을 높여주는 장점이 있다. - 자세한 설명은 장고 document 참고 https://docs.djangoproject.com/en/3.2/topics/http/decorators/ View decorators | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issu..

    django 15. Authentication 인증시스템 구축

    ※ Point 자신의 user페이지가 아닌 다른 user URL로 접근 가능한 문제 발생 아무나 접근 할 수 없도록 인증하는 Account app 생성함 Decolator 미사용 했을 경우의 인증 과정 views.py from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User from django.http import HttpResponseRedirect, HttpResponseForbidden from django.shortcuts import render # Create your views here. from django.urls import reverse, reverse_lazy f..

    django 14. DeleteView 기반 회원탈퇴 구현

    views.py class AccountDeleteView(DeleteView): model = User success_url = reverse_lazy('accountapp:login') template_name = 'accountapp/delete.html' 회원 탈퇴기능 DeleteView사용하여 구현 탈퇴 완료 후 login 페이지로 이동 urls.py from django.urls import path from accountapp.views import AccountDeleteView app_name = "accountapp" urlpatterns = [ path('delete/', AccountDeleteView.as_view(), name='delete'), ] 생성한 AccountDelet..

    django 13. UpdateView를 이용한 비밀번호 변경 구현

    views.py class AccountUpdateView(UpdateView): model = User form_class = AccountUpdateForm # 수정한 form으로 변경 success_url = reverse_lazy('accountapp:hello_world') template_name = 'accountapp/update.html' user 정보 수정하기 위해 장고 제공 함수인 updateView 사용 AccountUpdateForm 이름의 내가 정의한 forms.py 생성 수정 완료 후 메인화면인 hello_world로 이동 urls.py from django.urls import path from accountapp.views import AccountUpdateView app..

    django 12. DetailView 를 이용한 개인 페이지 구현

    views.py 추가 from django.contrib.auth.models import User from django.views.generic import DetailView from accountapp.models import HelloWorld class AccountDetailView(DetailView): model = User context_object_name = 'target_user' template_name = 'accountapp/detail.html' context_object_name을 user값으로 지정하면 다른 사람 페이지에서 내 유저정보만 볼 수 있는 문제 발생 target_user로 지정 후 좀 더 정확하게 user정보 표시 detail.html 생성 {% extends ..

    django 11. Login/ Logout 구현

    Login View / Logout View 장고 기본 제공하는 view 로그인, 로그아웃 views.py에 생성 안해도 됨 urls.py에 경로만 지정하면 알아서 생성됨 로그인 or 로그아웃 했을 경우, profile 경로로 이동할 경우 해결방법 http://127.0.0.1:8000/accounts/profile/ 로그인과 로그아웃을 번갈아가며 했을 경우, 이 경로로 자동으로 이동하게 된다. 이것은 장고 제공가 기본적으로 제공해주는 url이다. 이 경로로 이동하지 않기 위해 다음과 같이 설정한다. - settings.py 추가 LOGIN_REDIRECT_URL = reverse_lazy('accountapp:hello_world') LOGOUT_REDIRECT_URL = reverse_lazy('ac..

    django 10. CreateView 를 통한 회원가입 구현

    views.py class AccountCreateView(CreateView): # 장고에서 제공한 User테이블 불러오기 model = User # 장고에서 제공하는 UserCreationForm 불러오기, 인증 검증작업 form_class = UserCreationForm # reverse : 함수내에서 사용불가로 # reverse_lazy로 사용함, 링크연결 위함 / 라우팅 success_url = reverse_lazy('accountapp:hello_world') # 어느 app에서 볼껀지 설정, 사용자화면단 template_name = 'accountapp/create.html' create 함수인 생성 장고 기본 제공함수인 CreateView 가져옴 기본적으로 id, pw 등록 기능있음 u..

    django 09. 장고의 CRUD, class Based View

    https://docs.djangoproject.com/en/3.2/topics/class-based-views/ Class-based views | Django documentation | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com - 장고는 CRUD 기능(View)을 지원 해주는 것에 탁월함 Create View Read View Update View Delete View 4가지 View를 장고 패키지에서 기본으로 제공해준다 ->이것을 Class Base..