def get_comments_on_anywhere(user): content_type = ContentType.objects.get_for_model(Thing) user = User.objects.get(username=user.username) listemiz = list(Following.get_followed_username(user)) listemiz.append(user) comments = Comment.objects.filter( user__username__in=listemiz, content_type=content_type).order_by("-created_date") things = Thing.objects.filter( author__username__in=listemiz).order_by("-created_date") if comments and things: result_list = sorted(chain(things, comments), key=lambda instance: instance.created_date)[::-1] print(result_list[0]._meta.object_name) return result_list else: return False
def post_list_favorite_user(request, slug): page = request.GET.get('page', 1) blog = get_object_or_404(Blog, slug=slug) user_list = blog.get_added_favorite_user_as_object() paginator = Paginator(user_list, 1) try: user_list = paginator.page(page) except PageNotAnInteger: user_list = paginator.page(1) except EmptyPage: user_list = paginator.page(paginator.num_pages) my_followed_user = Following.get_followed_username(request.user) html = render_to_string('blog/include/favorite/favorite-user-list.html', context={'my_followed_user': my_followed_user, 'user_list': user_list}, request=request) page_html = render_to_string('blog/include/favorite/buttons/show_more_button.html', context={'post': blog, 'user_list': user_list}, request=request) return JsonResponse(data={'html': html, 'page_html': page_html})
def get_post_on_anywhere(user): user = User.objects.get(username=user.username) listemiz = list(Following.get_followed_username(user)) posts = Comment.objects.filter(user__username__in=listemiz) return posts
def explore(request): user = User.objects.get(username=request.user.username) listemiz = list(Following.get_followed_username(user)) print(type(listemiz)) comments = Comment.objects.filter(user__username__in=listemiz) pass