</div>
 
 
-  {% if doc %}
+  {% if stats %}
     <div class="card mt-4">
       <div class="card-header">
         <h2>{% trans "Statistics" %}</h2>
             </tr>
           </thead>
           <tbody>
-            {% with stats=doc.get_statistics %}
-              {% include 'documents/book_stats.html' with book=doc stats=stats depth=0 %}
-          {% endwith %}
+            {% include 'documents/book_stats.html' with book=doc stats=stats depth=0 %}
         </tbody>
       </table>
     </div>
 
     publish_error = book.publishable_error()
     publishable = publish_error is None
 
+    stats = None
     try:
         doc = book.wldocument(librarian2=True)
     except:
         doc = None
+    else:
+        try:
+            stats = doc.get_statistic()
+        except:
+            pass
 
     return render(request, "documents/book_detail.html", {
         "book": book,
         "doc": doc,
+        "stats": stats,
         "publishable": publishable,
         "publishable_error": publish_error,
         "form": form,