{ "info": { "author": "Greg Eremeev", "author_email": "gregory.eremeev@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django :: 1.11", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP" ], "description": "## django-context\n\n#### `django-context` is an BSD licensed library written in Python. It could be helpful for you if you wanna set some custom context in your django app. The one of the examples is add an extra info into your logging records. Also, you can use a request object in any place of an application cause this library provides a capability to reach it out at any time during a request.\n\n### Quick start\n\n1 install the library:\n```bash\npip install django-context\n```\n\n2 Add `django-context` to your INSTALLED_APPS setting like this:\n```Python\n INSTALLED_APPS = [\n ...\n django_context,\n ]\n```\n\n3 Add proxy middleware to your MIDDLEWARE setting like this:\n```Python\nMIDDLEWARE = [\n 'django_context.middleware.ProxyMiddleware',\n ...\n]\n```\nIt's important to place this `ProxyMiddleware` at the first place in a `MIDDLEWARE` to allow to calculate duration of response more precisely.\n\n4 If you just want to add info about request duration and request id to your log records then you can use `GlobalWSGIMiddleware` in your `wsgi.py` like this:\n```Python\napplication = GlobalWSGIMiddleware(get_wsgi_application())\n```\n\n5 Use this example of logging setting to set up your loggers correctly\n\n```Python\nLOGGING = {\n 'version': 1,\n 'formatters': {\n 'verbose': {\n 'format': ('[django] %(levelname)s %(asctime)s'\n ' %(name)s/%(module)s'\n ' %(process)d/%(thread)d'\n ' request_id: %(request_id)s'\n ' user_id: %(user_id)s'\n ' duration: %(response_duration)s'\n ' %(message)s')\n },\n },\n 'filters': {\n 'context_filter': {\n '()': 'django_context.logging.ContextFilter'\n }\n },\n 'handlers': {\n 'console': {\n 'level': 'INFO',\n 'class': 'logging.StreamHandler',\n 'formatter': 'verbose',\n 'filters': ['context_filter']\n }\n },\n 'loggers': {\n 'django_context': {\n 'level': 'INFO',\n 'handlers': ['console'],\n 'propagate': True,\n },\n 'django': {\n 'level': 'INFO',\n 'handlers': ['console'],\n 'propagate': True,\n },\n }\n}\n```\n\n### Log records example\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GregEremeev/django-context", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-context", "package_url": "https://pypi.org/project/django-context/", "platform": "", "project_url": "https://pypi.org/project/django-context/", "project_urls": { "Homepage": "https://github.com/GregEremeev/django-context" }, "release_url": "https://pypi.org/project/django-context/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Django app to have an ability to set custom context in a main application", "version": "0.1.1" }, "last_serial": 4668975, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "853b45a67f28216390554e7f069e6eb3", "sha256": "22fcf21acb1bb6f719515ef17b70960d6b5a1e8ab7b7ab7930c314a7fb26d771" }, "downloads": -1, "filename": "django-context-0.1.0.tar.gz", "has_sig": false, "md5_digest": "853b45a67f28216390554e7f069e6eb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5129, "upload_time": "2019-01-07T15:05:44", "url": "https://files.pythonhosted.org/packages/90/2c/c549b9c0d429dc666b3e92bc1deb63c25052c49b451f5a941abc699be9cf/django-context-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "6ac48a3af462dca6a0869226638c135d", "sha256": "54a47e3cb07dc1f71ac3e28e8c088f0f2bee8eb12f25e1e55d1c792701183eb1" }, "downloads": -1, "filename": "django-context-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6ac48a3af462dca6a0869226638c135d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5128, "upload_time": "2019-01-07T15:09:22", "url": "https://files.pythonhosted.org/packages/21/2e/685e3c9daf9747a756716b11c5b12c5c27aae726a39904984cc20403e139/django-context-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6ac48a3af462dca6a0869226638c135d", "sha256": "54a47e3cb07dc1f71ac3e28e8c088f0f2bee8eb12f25e1e55d1c792701183eb1" }, "downloads": -1, "filename": "django-context-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6ac48a3af462dca6a0869226638c135d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5128, "upload_time": "2019-01-07T15:09:22", "url": "https://files.pythonhosted.org/packages/21/2e/685e3c9daf9747a756716b11c5b12c5c27aae726a39904984cc20403e139/django-context-0.1.1.tar.gz" } ] }