Set order_by on AddressListView

Avoid pagination inconsistency
This commit is contained in:
Santiago L 2024-01-26 13:51:08 +01:00
parent d7e8a411cd
commit 76c18c0cae
2 changed files with 7 additions and 2 deletions

View File

@ -27,7 +27,7 @@ urlpatterns = [
path('bills/<int:pk>/download/', views.BillDownloadView.as_view(), name='bill-download'),
path('profile/', views.ProfileView.as_view(), name='profile'),
path('profile/setLang/<code>', views.profile_set_language, name='profile-set-lang'),
path('address/', views.MailView.as_view(), name='address-list'),
path('address/', views.AddressListView.as_view(), name='address-list'),
path('address/new/', views.MailCreateView.as_view(), name='address-create'),
path('address/<int:pk>/', views.MailUpdateView.as_view(), name='address-update'),
path('address/<int:pk>/delete/', views.AddressDeleteView.as_view(), name='address-delete'),

View File

@ -240,7 +240,7 @@ class BillDownloadView(CustomContextMixin, UserTokenRequiredMixin, View):
return HttpResponse(bill.html or bill.render())
class MailView(ServiceListView):
class AddressListView(ServiceListView):
service_class = AddressService
model = Address
template_name = "musician/addresses.html"
@ -249,6 +249,11 @@ class MailView(ServiceListView):
'title': _('Mail addresses'),
}
def get_queryset(self):
qs = super().get_queryset()
qs = qs.order_by("domain", "name")
return qs
def get_queryfilter(self):
"""Retrieve query params (if any) to filter queryset"""
domain_id = self.request.GET.get('domain')