Metadata-Version: 2.1
Name: django-stats-middleware
Version: 0.3
Summary: Django Middleware for reporting very simple lightweight timing stats at end of ever page.
Home-page: https://github.com/bernd-wechner/django-stats-middleware
Author: Bernd Wechner
Author-email: bwechner@yahoo.com
Project-URL: Bug Tracker, https://github.com/bernd-wechner/django-stats-middleware/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: Freely Distributable
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django :: 4.0
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.md

# Django Stats Middleware

[Django](https://www.djangoproject.com/) is one of the most popular Python web frameworks today.

When a Django site seems slow, it's nice to put some real number to to that. The [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/en/latest/) is the go-to middleware solution for diagnosing Django performance among other things, but it is rather large, and slow itself, adding significantly to the load time of your pages. So it's in a bit of catch-22 bind for simple performance overviews.

For that reason I wrote this tiny little lightweight piece of middleware that reports at the bottom of every page a single line reporting some basic timing stats. 

- **Total Time**: The time from the request arriving to the response being delivered.
- **Python Time**: Time spent running Python code
- **DB Time**: Time spent waiting on database queries
- **Number of Queries**: The number of database queries run

Where:

​	Python Time + DB Time = Total Time

Here's an example:

![sample](https://raw.githubusercontent.com/bernd-wechner/django-stats-middleware/master/sample.png)

To use it just put it at the top of your Django Middleware stack:

```python
MIDDLEWARE = (
    'django_stats_middleware.StatsMiddleware',
	...
```

That way Total Time will include the time spent in all other middleware as well as your site code.

It includes some minimal CSS and to include that in your site include it as an app (so Django knows to collect static files from it):

```python
    INSTALLED_APPS += (
        'django_stats_middleware',
    )
```

and in your template load the CSS:

```html
    {% load static %}
    <link rel="stylesheet" type="text/css" href="{% static 'django-stats-middleware/css/default.css' %}" />
```



