'Dynamic Django urls redirects to the wrong function

So what I am trying to do is create urls such that the user can see complaints either by passing a particular parameter or sort by upvotes by default if no parameter is passed.

urls.py

path('', views.exploreComplaints, name='explore-complaints'),
path('?sort_by=<str:sorting_parameter>/', views.exploreComplaints, name='explore-complaints-by-parameter'),

views.py

def exploreComplaints(request, sorting_parameter="upvotes"):
    complaints = Complaint.objects.all()
    if(sorting_parameter=="name"):
        complaints = sorted(complaints, key = lambda x : x.complaint_name)
    else:
        complaints = sorted(complaints, key = lambda x : x.complaint_upvotes, reverse = True)
    context = {'complaints':complaints}
    return render(request, 'complaints/complaints.html', context)

The sorting parameter does not work when I go to a URL, the value of sorting_parameter is always upvotes, even when I go to a url with ?/sort_by=name in the end. Where am I wrong?

Edit: Complaint Model:

class Complaint(models.Model):
    complaint_title =                   models.CharField(max_length = 1000, null = True)
    complaint_filer =                   models.ForeignKey(User, null = True, on_delete = models.CASCADE)
    complaint_description =             models.TextField(null = True)
    complaint_status =                  models.CharField(max_length = 10, default = 'active')
    complaint_request_image =           models.ImageField(null = True, blank = True, upload_to = 'complaints', default = 'complaints/default-image.jpg')
    complaint_place =                   models.CharField(max_length = 1000, null = True)
    complaint_under_investigation_by =  models.CharField(max_length = 1000, null = True, blank = True)
    complaint_upvotes =                 models.IntegerField(default = 0)
    complaint_upvotes_users =           models.TextField(default=',', blank = True)
    complaint_downvotes_users =         models.TextField(default=',', blank = True)
    tags = TaggableManager()

    def __str__(self):
        return self.complaint_title


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source