diff --git a/avisstage/views.py b/avisstage/views.py index effc4ad..b947158 100644 --- a/avisstage/views.py +++ b/avisstage/views.py @@ -54,6 +54,7 @@ class StageView(LoginRequiredMixin, DetailView): filtre = Q(auteur__user_id=self.request.user.id) | Q(public=True) return Stage.objects.filter(filtre) + # Liste des stages par dernière modification #login_required class StageListe(LoginRequiredMixin, ListView): diff --git a/avisstage/views_search.py b/avisstage/views_search.py index 427a055..cbf156c 100644 --- a/avisstage/views_search.py +++ b/avisstage/views_search.py @@ -138,6 +138,7 @@ def recherche_resultats(request): form = SearchForm(request.GET) if form.is_valid(): stages, tri = cherche(**form.cleaned_data) + stages = stages.prefetch_related('lieux', 'auteur', 'matieres', 'thematiques') lieux = map(list, stages.values_list('id', 'lieux')) else: form = SearchForm() diff --git a/experiENS/settings_dev.py b/experiENS/settings_dev.py index 4c894ce..ba98c0e 100644 --- a/experiENS/settings_dev.py +++ b/experiENS/settings_dev.py @@ -15,9 +15,11 @@ INSTALLED_APPS += ( 'debug_toolbar', ) -MIDDLEWARE_CLASSES += ( +MIDDLEWARE_CLASSES = ( 'debug_toolbar.middleware.DebugToolbarMiddleware', -) +) + MIDDLEWARE_CLASSES + +INTERNAL_IPS = ['127.0.0.1'] SPATIALITE_LIBRARY_PATH = 'mod_spatialite' diff --git a/experiENS/urls.py b/experiENS/urls.py index 58d25b7..c247442 100644 --- a/experiENS/urls.py +++ b/experiENS/urls.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.conf.urls import include, url from django.contrib import admin @@ -12,3 +13,9 @@ urlpatterns = [ url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')), url(r'^admin/', include(admin.site.urls)), ] + +if settings.DEBUG: + import debug_toolbar + urlpatterns = [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] + urlpatterns