Cant view my user profile, it shows an exception. #11213

Closed
opened 2025-12-29 21:42:00 +01:00 by adam · 4 comments
Owner

Originally created by @jakobsen-lrz on GitHub (May 22, 2025).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.3.1

Python Version

3.11

Steps to Reproduce

  1. Have user that has more than 20 Entries in the changelog
  2. With that user, open its User Profile

Expected Behavior

It shows the Users Profile.

Observed Behavior

It showed an exception without Traceback. The Exception was of the type TypeError and said Cannot reorder a query once a slice has been taken.. This Exception originates from the Method order_by in the class QuerySet from django.db.model.query.

Originally created by @jakobsen-lrz on GitHub (May 22, 2025). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.3.1 ### Python Version 3.11 ### Steps to Reproduce 1. Have user that has more than 20 Entries in the changelog 2. With that user, open its User Profile ### Expected Behavior It shows the Users Profile. ### Observed Behavior It showed an exception without Traceback. The Exception was of the type `TypeError `and said `Cannot reorder a query once a slice has been taken.`. This Exception originates from the Method `order_by` in the class `QuerySet ` from `django.db.model.query`.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:42:00 +01:00
adam closed this issue 2025-12-29 21:42:01 +01:00
Author
Owner

@jakobsen-lrz commented on GitHub (May 22, 2025):

This Bug was added through pull request #19390 . In the ProfileView Class in netbox/account/views.py in line 200 a call to the configure method was added.

class ProfileView(LoginRequiredMixin, View):
    template_name = 'account/profile.html'

    def get(self, request):

        # Compile changelog table
        changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter(
            user=request.user
        ).prefetch_related(
            'changed_object_type'
        )[:20]
        changelog_table = ObjectChangeTable(changelog)
        changelog_table.configure(request)

        return render(request, self.template_name, {
            'changelog_table': changelog_table,
            'active_tab': 'profile',
        })

The Problem is that the QuerySet, that is displayed in the table, is sliced to only include the first 20 Results. The table cant be reordered because it has been sliced. One solution would be to remove the call to configure, i cant find a better solution. Is it maybe possible to reduce a QuerySet without slicing?

@jakobsen-lrz commented on GitHub (May 22, 2025): This Bug was added through pull request #19390 . In the ProfileView Class in netbox/account/views.py in line 200 a call to the configure method was added. ``` class ProfileView(LoginRequiredMixin, View): template_name = 'account/profile.html' def get(self, request): # Compile changelog table changelog = ObjectChange.objects.valid_models().restrict(request.user, 'view').filter( user=request.user ).prefetch_related( 'changed_object_type' )[:20] changelog_table = ObjectChangeTable(changelog) changelog_table.configure(request) return render(request, self.template_name, { 'changelog_table': changelog_table, 'active_tab': 'profile', }) ``` The Problem is that the QuerySet, that is displayed in the table, is sliced to only include the first 20 Results. The table cant be reordered because it has been sliced. One solution would be to remove the call to configure, i cant find a better solution. Is it maybe possible to reduce a QuerySet without slicing?
Author
Owner

@jakobsen-lrz commented on GitHub (May 22, 2025):

This Bug probably wasnt noticed, as the slicing does nothing if the changelog table contains less than 20 entries.

@jakobsen-lrz commented on GitHub (May 22, 2025): This Bug probably wasnt noticed, as the slicing does nothing if the changelog table contains less than 20 entries.
Author
Owner

@jakobsen-lrz commented on GitHub (May 23, 2025):

I just saw that this Problem needs to be fixed in another file as well, i replied on the pull request in more detail where it would need to be fixed.

@jakobsen-lrz commented on GitHub (May 23, 2025): I just saw that this Problem needs to be fixed in another file as well, i replied on the pull request in more detail where it would need to be fixed.
Author
Owner

@jeremystretch commented on GitHub (Jun 3, 2025):

Going to close this out as I believe the root issue has been identified and addressed under bug #19599.

@jeremystretch commented on GitHub (Jun 3, 2025): Going to close this out as I believe the root issue has been identified and addressed under bug #19599.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11213