from __future__ import absolute_import, unicode_literals

from django.views.generic import DetailView, ListView

from .models import District


class DistrictListView(ListView):
    queryset = District.objects.all().select_related('county__name')


class DistrictDetailView(DetailView):
    queryset = District.objects.all().prefetch_related('stats__year')
    pk_url_kwarg = 'district_id'
    slug_url_kwarg = 'district_slug'

from __future__ import absolute_import, unicode_literals

from django.views.generic import DetailView, ListView

from .models import District


class DistrictListView(ListView):
    queryset = District.objects.all().defer('shape')


class DistrictDetailView(DetailView):
    queryset = District.objects.all().prefetch_related('stats__year')
    pk_url_kwarg = 'district_id'
    slug_url_kwarg = 'district_slug'

Remove unused select_related, defer the loading of shape for speed
Remove unused select_related, defer the loading of shape for speed

  from __future__ import absolute_import, unicode_literals
  
  from django.views.generic import DetailView, ListView
  
  from .models import District
  
  
  class DistrictListView(ListView):
-     queryset = District.objects.all().select_related('county__name')
+     queryset = District.objects.all().defer('shape')
  
  
  class DistrictDetailView(DetailView):
      queryset = District.objects.all().prefetch_related('stats__year')
      pk_url_kwarg = 'district_id'
      slug_url_kwarg = 'district_slug'
  
Remove unused select_related, defer the loading of shape for speed
## Code Before:
from __future__ import absolute_import, unicode_literals

from django.views.generic import DetailView, ListView

from .models import District


class DistrictListView(ListView):
    queryset = District.objects.all().select_related('county__name')


class DistrictDetailView(DetailView):
    queryset = District.objects.all().prefetch_related('stats__year')
    pk_url_kwarg = 'district_id'
    slug_url_kwarg = 'district_slug'

## Instruction:
Remove unused select_related, defer the loading of shape for speed
## Code After:
from __future__ import absolute_import, unicode_literals

from django.views.generic import DetailView, ListView

from .models import District


class DistrictListView(ListView):
    queryset = District.objects.all().defer('shape')


class DistrictDetailView(DetailView):
    queryset = District.objects.all().prefetch_related('stats__year')
    pk_url_kwarg = 'district_id'
    slug_url_kwarg = 'district_slug'
