Metadata-Version: 2.1
Name: django-exception
Version: 1.0.0
Summary: Django python exception model, admin, logging handler, middleware and excepthook
Keywords: django
Classifier: Framework :: Django
Classifier: License :: Public Domain
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Description-Content-Type: text/markdown

### Installation
```bash
$ pip install django-exception
```

#### `settings.py`
```python
INSTALLED_APPS+=['django_exception']
```

#### `migrate`
```bash
$ python manage.py migrate
```

#### Models/tables
model|table|columns/fields
-|-|-
`ExceptionModel`|`django_exception`|id,module,filename,lineno,exc_class,exc_message,exc_traceback,timestamp
### Examples
`settings.py`
```python
LOGGING = {
    "version": 1,
    "handlers": {
        "console": {
            "level": "DEBUG",
            "class": "logging.StreamHandler",
        },
        "django_exception": {
            "level": "ERROR",
            "class": "django_exception.ExceptionLogHandler",
        }
    },
    "root": {
        "handlers": ["console", "django_exception"],
        "level": "DEBUG",
    },
    "loggers": {
        "django_exception": {
            "level": "ERROR",
            "handlers": ["django_exception"],
            "propagate": True,
        },
    },
}

MIDDLEWARE = [
    "django_exception.middleware.ExceptionMiddleware",
]
```

`sys.excepthook` - log all exceptions
```python
import sys
import django_exception

def excepthook(exc_type, exc_message, tb):
	django_exception.excepthook(exc_type, exc_message, tb)
	raise exc_type(exc_message)

sys.excepthook = excepthook
```

