djangoでのこれらの使い分けがわかりません。
どのような時に使い分ければいいのでしょうか?
また同じクラス内で使っても問題ないでしょうか?
問題なく動きます
よろしくおねがいいたします。
class IndexView(TemplateView): template_name = 'qs_posts/index.html' paginate_by = 1 def get(self, request, *args, **kwargs): context = { 'post_list':QuestionPost.objects.order_by('-created_at'), } return render(request, 'qs_posts/index.html',context) def get_queryset(self): queryset = QuestionPost.objects.order_by('-created_at') keyword = self.request.GET.get('keyword') if keyword: queryset = queryset.filter( Q(title__icontains=keyword) | Q(text__icontains=keyword) ) return queryset
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/23 06:56