- Django
- 1:n
- many to many relationships
- Article & User
- 댓글 READ
- delete
- create
- prefetch_related
- 댓글 create
- migrations
- 게시글
- 역참조
- dumpdata
- n:1의 한계 상황
- Migrate
- 쟝고
- ManyToManyField
- DB
- 중개모델
- http
- N:1
- queryset api
- ORM
- improve query
- Read
- M:N
- 댓글 update
- comment & user
- update
- select_related
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
목록댓글 READ (2)
데이터 분석 기술 블로그
1. 댓글 CREATE댓글 작성 시 이전에 게시글 작성할 때와 동일한 에러가 발생합니다. 댓글의 user_id 필드 데이터가 누락되었기 때문입니다.댓글 작성 시 작성자 정보가 함께 저장할 수 있도록 작성합니다.# articles/views.pydef comments_create(request, pk): article = Article.objects.get(pk=pk) comment_form = CommentForm(request.POST) if comment_form.is_valid(): comment = comment_form.save(commit=False) comment.article = article comment.user = request.u..
1. 댓글 READ 구현 detail view 함수에서 전체 댓글 데이터를 조회 # articles/views.py from .models import Article, Comment def detail(request, pk): article = Article.objects.get(pk=pk) comment_form = CommentForm() comments = article.comment_set.all() context = { 'article': article, 'comment_form': comment_form, 'comments': comments, } return render(request, 'articles/detail.html', context) 댓글 목록 {% for comment in co..