BackEnd/Django (40) 썸네일형 리스트형 [Webpack]Setting 이런 패키지 개발환경 생성하는게 더 힘들다 ... 일단 packeage.json생성을 위해 npm init 이후 npm i -g webpack webpack-cli && npm i -D webpack webpack-cli 를 통해 웹팩을 설치하자 i = install 이 때 커맨드로 설치 할 시에, 관리자 권한으로 실행 powershell에선 그냥 실행해서 될 때까지 해봐야 함 ㅠㅠ 설치가 됬다면 webpack.config. js파일 index.js파일을 만들자 webpack.config.js는 어떻게 웹팩을 다룰 건지에 대한 것을 적을꺼임 const path = require("path")const webpack = require("webpack")const UglifyJsPlugin = require.. [Django] User password Change class ChangePassword(APIView): def put(self, request, username, format=None): user = request.user if user.username == username : current_password = request.data.get('current_password',None) if current_password is not None: password_match = user.check_password(current_password) if password_match : new_password = request.data.get('new_password',None) if new_password is not None: user.set_password(.. [Django]User Profile 수정하기 class UserProfile(APIView): def get_user(self, username): try : found_user = models.User.objects.get(username=username) return found_user except models.User.DoesNotExist: return None def put(self, request, username, format=None): user = request.user found_user = self.get_user(username) if found_user is None: return Response(status=status.HTTP_404_NOT_FOUND) elif found_user.username != user.usern.. [Django] 이미지 삭제하기 class ImageDetail(APIView): def find_own_image(self, image_id, user): try: image = models.Image.objects.get(id=image_id, creator=user) return image except models.Image.DoesNotExist: return None def put(self, request, image_id, format_=None): user = request.user image = self.find_own_image(image_id, user) if image is None: return Response(status=status.HTTP_401_UNAUTHORIZED) serializer = serializ.. [Django] 이미지 수정하기! class ImageDetail(APIView): def get(self, request, image_id, format=None): user = request.user try: image = models.Image.objects.get(id=image_id) except models.Image.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) serializer =serializers.ImageSerializer(image) return Response(data=serializer.data, status=status.HTTP_200_OK) def put(self, request, image_id, format_=None): user = r.. [Django] 좋아요 리스트 보기 class LikeImage(APIView): def post(self, request , image_id , format=None): user = request.user try : found_image = models.Image.objects.get(id=image_id) except models.Image.DoesNotExist: return Response(status=status.HTTP_204_NO_CONTENT) try: preexisting_like = models.Like.objects.get( creator = user, image=found_image ) return Response(status=status.HTTP_304_NOT_MODIFIED) except : new_like = m.. [Django]단일 이미지 보기 path("", view=views.ImageDetail.as_view(), name="ImageDetail"), class ImageDetail(APIView): def get(self, request, image_id, format=None): user = request.user try: image = models.Image.objects.get(id=image_id) except models.Image.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) serializer =serializers.ImageSerializer(image) return Response(data=serializer.data, status=status.HTTP_.. [Django]내 이미지 댓글 지우기 [질문중] 이전에 나의 댓글 지우는 기능을 만들었는데 이번에는 내 이미지에 있는 댓글을 지우는 기능을 만들어 볼꺼임 ㅇㅇ path("/comments/", view=views.ModerateComments.as_view(), name="ModerateComments"), 다음과 같이 URL을 지정하고 class ModerateComments(APIView): def delete(self, request, image_id, comment_id, format=None): user = request.user try: comment_to_delete = models.Comment.objects.get( id=comment_id, image__id=image_id, image__creator=user) comment_to_.. 이전 1 2 3 4 5 다음