###########
Django-Care
###########

.. image:: https://pypip.in/wheel/django-care/badge.svg
    :target: https://pypi.python.org/pypi/django-care/
    :alt: Wheel Status

.. image:: https://pypip.in/version/django-care/badge.svg
    :target: https://pypi.python.org/pypi/django-care/
    :alt: Latest Version

.. image:: https://pypip.in/license/django-care/badge.svg
    :target: https://pypi.python.org/pypi/django-care/
    :alt: License


Goal
====

Provide tool which help finding performance issues in django projects.

Installation
============

Install requirements:

.. code-block:: console
    
    pip install -r requirements.txt

Install django-care:

.. code-block:: console

   pip install django-care

or current development version:

.. code-block:: console

   pip install hg+https:://bitbucket.org/kidosoft/django-care

Configuration
=============

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'care',
        ...
    )

Usage
=====

Checking for queries run at startup
-----------------------------------

Running command below will statistics about queries run at project startup.

.. code-block:: console

    $ python manage.py check_startup_queries -o queries.txt

Enabling SQL queries annotations
--------------------------------

In order to get sql queries annotated with path and view in which it occured
add middleware as below.

.. code-block:: python

    MIDDLEWARE_CLASSES += ('care.middleware.AnnotateSQLMiddleware',)

Issued queries will have comment appended in the form::

    <original query> -- path: <request path> | view: <resolved view>

For example:

.. code-block:: sql

    SELECT `id`, `username` FROM `auth_user` WHERE `id` = 1 -- path: / | view: base.index

It can help with searching for source of slow queries from slow.log.


Supported Django versions
=========================

Tested with: 

* Django 1.2.7 on python2.7
* Django 1.3.7 on python2.7
* Django 1.4.16 on python2.7
* Django 1.5.11 on python2.7, python3.2, python3.3, python3.4
* Django 1.6.8 on python2.7, python3.2, python3.3, python3.4
* Django 1.7.1 on python2.7, python3.2, python3.3, python3.4

Documentation
=============

http://kidosoft.pl/docs/django-care/
