{ "info": { "author": "Counsyl", "author_email": "root@counsyl.com", "bugtrack_url": null, "classifiers": [], "description": "# django-pedant\n\nMake Django templates fail fast on a variety of errors.\n\n\"This\n
Source: [Flickr:karen_od](https://www.flickr.com/photos/karen_od/33199)\n\nIt's happened to all of us. We forget a template variable in a context, or\nhave a bug in a property accessed in a template. Django, a battle-forged web\nframework, was designed to **serve the damn webpage no matter what**, much to\nthe chagrin of web developers who have found easily fixable bugs going unfixed\nfor months. It's the worst. It's literally like getting stabbed in the back and left to\nbleed out, muttering \"Et tu, Django?\" with your last breaths. *Literally.* It's\nthat bad.\n\nEnter django-pedant, the pedantic template renderer's friend.\n\n## What is this package pedantic about?\nI think you mean \"about what is this package pedantic?\" Seriously, though, Django\nis very lenient in at least the following ways:\n- Exceptions raised in computing `{% if expression %}` expressions other builtin tags.\n In general, errors in custom tags are allowed to propagate.\n- `KeyError` and `AttributeError` in `{{ context_variable }}` expressions.\n- `UnicodeDecodeError` is caught in some places and replaced with `''` (TODO)\n- In evaluating `{{ expr|filter }}` expressions, `FilterExpression.resolve` has\n `ignore_failures=True` in some case, which swallows `VariableDoesNotExist` errors.\n\n## Usage\n\nTo decorate your view which might hide template failures, simply do:\n```python\nfrom pedant.decorators import fail_on_template_errors\n\n@fail_on_template_errors\ndef my_view(request):\n # [...]\n return render_to_string('foo.html')\n```\n\nIf there are errors in `foo.html`, the view will now raise a `PedanticTemplateRenderingError`\nif there were any errors in rendering the template that Django swallows.\n\nTo simply *log* if there are template failures, you can use the `log_on_template_errors` decorator:\n```python\nimport logging\n\nfrom pedant.decorators import log_on_template_errors\n\nlogger = logging.getLogger('myapp.views')\n\n@log_on_template_errors(logger, log_level=logging.INFO)\ndef my_view(request):\n # [...]\n return render_to_string('foo.html')\n```\nThis will log template errors to the `myapp.views` logger at `INFO`. The default log level\nis `logging.ERROR`.\n\nFor using pedantic rendering in your view tests, you can simply inherit from `PedanticTestCase`:\n```python\nfrom django.template import Template, Context\nfrom pedant.utils import PedanticTestCase\n\nclass TestBuggyTemplate(PedanticTestCase):\n def test(self):\n Template('{{ foo }}').render(Context({'bar': 'baz'}))\n```\nThat test will fail since `foo` is undefined in the template. `PedanticTestCase` inherits from\nthe standard Django `TestCase`. `PedanticTestCaseMixin` is also provided if you don't want to\nincur the transactional overhead of Django's test case (e.g. for unit tests).\n\n\n## Test\n\n```sh\n$ tox\n```\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/counsyl/django-pedant", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-pedant", "package_url": "https://pypi.org/project/django-pedant/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-pedant/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/counsyl/django-pedant" }, "release_url": "https://pypi.org/project/django-pedant/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Make django templates fail fast on errors", "version": "1.0.1" }, "last_serial": 2115037, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "334debba21937e78b38cecbf2e746b4a", "sha256": "241010f64921311e34bfd39323d39775fdbaa084789bcb734ffc6cccc1fb2abe" }, "downloads": -1, "filename": "django-pedant-0.0.5.tar.gz", "has_sig": false, "md5_digest": "334debba21937e78b38cecbf2e746b4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8510, "upload_time": "2014-09-24T18:39:47", "url": "https://files.pythonhosted.org/packages/a9/ef/1138e43ede7787b1cb182ff4c18519c660cd137f9bbbd8eaa2db8a81c849/django-pedant-0.0.5.tar.gz" } ], "1.0.0": [], "1.0.1": [ { "comment_text": "", "digests": { "md5": "45a5f7aba456a6fddc0a8ad31bc8efc2", "sha256": "cd18c86ddff8bcf167e61da9ff65f9364984539ed93d54bbd41fa4ebb4321918" }, "downloads": -1, "filename": "django-pedant-1.0.1.tar.gz", "has_sig": false, "md5_digest": "45a5f7aba456a6fddc0a8ad31bc8efc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8798, "upload_time": "2016-05-13T23:43:32", "url": "https://files.pythonhosted.org/packages/24/86/115c4ee22780ec85380a5c1a06742ec75828aa8cc8cfb5fb9cc5cd64bbed/django-pedant-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "45a5f7aba456a6fddc0a8ad31bc8efc2", "sha256": "cd18c86ddff8bcf167e61da9ff65f9364984539ed93d54bbd41fa4ebb4321918" }, "downloads": -1, "filename": "django-pedant-1.0.1.tar.gz", "has_sig": false, "md5_digest": "45a5f7aba456a6fddc0a8ad31bc8efc2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8798, "upload_time": "2016-05-13T23:43:32", "url": "https://files.pythonhosted.org/packages/24/86/115c4ee22780ec85380a5c1a06742ec75828aa8cc8cfb5fb9cc5cd64bbed/django-pedant-1.0.1.tar.gz" } ] }