Query Chain not returning anything when it's supposed to

In this view, when hashtag only is provided its fine, when sortby is anything except for the handled cases it’s fine, when there’s hashtag AND any sortBy handled (like Popular) nothing is returned when it shouldn’t because all Popular does is sorting and the texts already exist because they’re returned when only hashtag is provided, Here’s the view:

@login_required
def get_texts(request):
    updated_texts = []
    sortBy = request.GET.get('sortBy')
    hashtag = request.GET.get('hashtag')
    search_query = request.GET.get('search', '').strip()

    base_query = HiveText.objects.all()

    if hashtag:
        base_query = base_query.filter(caption__icontains=f"#{hashtag}")

    if search_query:
        base_query = base_query.filter(caption__icontains=search_query)

    if sortBy == "Popular":
        texts = base_query.order_by("-like_counter", "-created_date")
    
    elif sortBy == "iMessages":
        texts = base_query.filter(capturetype="iMessages").order_by("-created_date")
    
    elif sortBy == "Dating Apps":
        texts = base_query.filter(capturetype="Dating Apps").order_by("-created_date")

    elif sortBy == "Social Media":
        texts = base_query.filter(capturetype="Social Media").order_by("-created_date")
    
    else:
        texts = base_query.order_by("-created_date")

    texts = texts[:20]

    for text in texts:
        try:
            image_filenames = json.loads(text.content)
        except json.JSONDecodeError:
            image_filenames = []
        
        updated_texts.append({
            'item': text,
            'image_filenames': image_filenames,
        })

    return render(
        request,
        "hive_text.html",
        {
            "texts": updated_texts,
        },
    )

Welcome @Mazeniify !

Please post the complete URL (including all query variables) that is being requested.

Hey @KenWhitesell, after checking the url I found out I had url params seperated by “?” instead of “&”, so it wasn’t really a django problem, Thanks for your help I appreciate it.

Url I was using:

.../texts?hashtag=boo?sortBy=Popular