Commits

svevang  committed b5ea964

select related, speed things up

  • Participants
  • Parent commits 519f149

Comments (0)

Files changed (1)

File datamoose/views.py

 
 # Some caching constructs
 def fetch_data_output(request, datamoose_slug, data_output_slug, **kwargs):
-  return get_object_or_404(DataOutput, slug=data_output_slug, datamoose__slug=datamoose_slug)
+  try:
+    return DataOutput.objects.select_related().get(slug=data_output_slug, datamoose__slug=datamoose_slug)
+  except DataOutput.DoesNotExist:
+    raise Http404
 
 def output_last_modified(*args, **kwargs):
   data_output = fetch_data_output(*args, **kwargs)