views.py 675 B

12345678910111213141516171819202122
  1. from django.db.models import Count
  2. from django.views import generic
  3. from locations.models import GeoLocation
  4. from scrobbles.stats import get_scrobble_count_qs
  5. class GeoLocationListView(generic.ListView):
  6. model = GeoLocation
  7. paginate_by = 75
  8. def get_queryset(self):
  9. return super().get_queryset().filter(scrobble__user_id=self.request.user.id).order_by("-created")
  10. def get_context_data(self, **kwargs):
  11. context_data = super().get_context_data(**kwargs)
  12. context_data["latest"] = self.get_queryset().first()
  13. return context_data
  14. class GeoLocationDetailView(generic.DetailView):
  15. model = GeoLocation
  16. slug_field = "uuid"