I am getting an error for only one table on django admin panel.
We are using two managers.
- Default manager
- 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
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
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.
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.