# hourglass icon issue on django admin page for a table

**URL:** <https://forum.djangoproject.com/t/hourglass-icon-issue-on-django-admin-page-for-a-table/37622>\
**Category:** The Admin\
**Created:** [January 2, 2025, 9:56am UTC](https://forum.djangoproject.com/t/hourglass-icon-issue-on-django-admin-page-for-a-table/37622 "2025-01-02T09:56:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dr-Django](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dr-django/32/19478_2.png) [@Dr-Django](https://forum.djangoproject.com/u/Dr-Django)\
**Post date:** [January 2, 2025, 9:56am UTC](https://forum.djangoproject.com/t/hourglass-icon-issue-on-django-admin-page-for-a-table/37622/1 "2025-01-02T09:56:07Z")

</div>

I am getting an error for only one table on django admin panel.

We are using two managers.

1. Default manager
2. Custom manager

For admin panel, I have been using default manager to allow superusers to see `archived` data as well. That’s why we are using custom manger where i am excluding archived records from queryset.

I have debugged the admin view code and tried to intercept the request after hitting request from admin panel.

Admin view is successfully returning queryset. After that, I don’t know where it’s going actually.

I will share screenshots below, what’s the actual behaviour of request from admin panel.

- It took around 30 seconds for processing:

- After that it got hourglass icon

- Then

- Finally

> Total duration to process the request was more than one minute. It’s quite awkward.

**model**

```auto
class CandidateAssessment(models.Model):
    candidate = models.ForeignKey(
        Candidate, on_delete=models.CASCADE, null=True, blank=True)
    assessment = models.ForeignKey(
        'Assessment.Assessment', on_delete=models.CASCADE, null=True, blank=True)
    report = models.ForeignKey(
        CandidateAssessmentReport, on_delete=models.CASCADE, null=True, blank=True
    )
    status = models.ForeignKey(
        CandidateAssessmentStatus, on_delete=models.CASCADE, null=True, blank=True)
    modify_at = models.DateTimeField(auto_now=True, null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)

    objects = CustomManager()
    all_objects = models.Manager()

    def __str__ (self) -> str:
        return str(self.id)

    class Meta:
        verbose_name = 'Candidate Assessment'
        verbose_name_plural = 'Candidate Assessments'

```

**admin**

```auto
class CandidateAssessmentAdmin(admin.ModelAdmin):
    def get_queryset(self, request):
        return CandidateAssessment.all_objects.all()
    list_display = (
        'id', 'candidate', 'assessment', 'report',
        'status', 'modify_at', 'created_at',
    )
    search_fields = ['id', 'candidate __first_name', 'candidate__ email',
                     'candidate __surname', 'assessment__ name', 'status__name']

```

* * *

I have intercepted request on this line where I used debug-console to query with default manager. It returned all objects in micro seconds.

```auto
return CandidateAssessment.all_objects.all()

```

In my opinion, It’s stuck somewhere in processing HTML template because admin view is returning queryset simultaneously.

Thank you for reading!

I would prior solution suggestion. Please do contribute to fix this issue.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 2, 2025, 12:49pm UTC](https://forum.djangoproject.com/t/hourglass-icon-issue-on-django-admin-page-for-a-table/37622/2 "2025-01-02T12:49:30Z")

</div>

Welcome @Dr-Django !

> [@Dr-Django](#):
>
> It returned all objects in micro seconds.
> 
> ```auto
> return CandidateAssessment.all_objects.all()
> 
> ```

This is an incorrect statement.

This `return` statement actually returns a queryset, which is not executed as a query until the contents of the queryset are referenced. As a result, Django refers to querysets as being lazy - see [Querysets are lazy](https://docs.djangoproject.com/en/5.1/topics/db/queries/#querysets-are-lazy) and [When `QuerySet`s are evaluated](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#when-querysets-are-evaluated).

Depending upon the number of related objects from those FK fields, I’m guessing that the time is mostly being spent rendering all the option values in the drop-downs for the selects being generated for those FK fields. It may also be generating a _very_ large web page that is taking a lot of time being rendered by your browser. You can get an idea of this by looking at the size of the page returned.

The [Django Debug Toolbar](https://docs.djangoproject.com/en/5.1/intro/tutorial08/#installing-django-debug-toolbar) would give you a much clearer picture as to where the time is being spent.

---

<div class="post-metadata">

**Author:** ![Dr-Django](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dr-django/32/19478_2.png) [@Dr-Django](https://forum.djangoproject.com/u/Dr-Django)\
**Post date:** [January 2, 2025, 1:30pm UTC](https://forum.djangoproject.com/t/hourglass-icon-issue-on-django-admin-page-for-a-table/37622/3 "2025-01-02T13:30:30Z")

</div>

@KenWhitesell

Thanks for welcoming me!

You’re right! it was my mistake regarding the queryset statement. I used the `changelist_view` method in the admin view class to calculate the page size, which gave me this result:

```auto
Page size: 71256 bytes (69.59 KB)

```

Instead of using:

> [@KenWhitesell](#):
>
> [Django Debug Toolbar](https://docs.djangoproject.com/en/5.1/intro/tutorial08/#installing-django-debug-toolbar)

I plan to profile the admin view using **django-silk**. I’ll dig deeper into this and get back to you with my findings.
