{"id":408,"date":"2018-01-18T18:35:51","date_gmt":"2018-01-18T18:35:51","guid":{"rendered":"http:\/\/library.brown.edu\/DigitalTechnologies\/?p=408"},"modified":"2018-01-18T18:35:51","modified_gmt":"2018-01-18T18:35:51","slug":"python-django-warnings","status":"publish","type":"post","link":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/python-django-warnings\/","title":{"rendered":"Python\/Django warnings"},"content":{"rendered":"<p>I recently updated a Django project from 1.8 to 1.11. In the process, I started turning warnings into errors. Django docs <a href=\"https:\/\/docs.djangoproject.com\/en\/1.11\/howto\/upgrade-version\/#resolving-deprecation-warnings\">recommend<\/a> resolving any deprecation warnings with current version, before upgrading to a new version of Django. In this case, I didn&#8217;t start my upgrade work by resolving warnings, but I did run the tests with warnings enabled for part of the process.<\/p>\n<p>Here&#8217;s how to enable all warnings when you&#8217;re running your tests:<\/p>\n<ol>\n<li><a href=\"https:\/\/docs.python.org\/3\/using\/cmdline.html#cmdoption-w\">From the CLI<\/a>\n<ul>\n<li>use -Werror to raise Exceptions for all warnings<\/li>\n<li>use -Wall to print all warnings<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/warnings.html#the-warnings-filter\">In the code<\/a>\n<ul>\n<li>import warnings; warnings.filterwarnings(&#8216;error&#8217;) &#8211; raise Exceptions on all warnings<\/li>\n<li>import warnings; warnings.filterwarnings(&#8216;always&#8217;) &#8211; print all warnings<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>If a project runs with no warnings on a Django LTS release, it&#8217;ll (generally) <a href=\"https:\/\/www.djangoproject.com\/weblog\/2015\/jun\/25\/roadmap\/\">run on the next LTS release<\/a> as well. This is because Django intentionally tries to <a href=\"https:\/\/docs.djangoproject.com\/en\/1.11\/internals\/release-process\/#deprecation-policy\">keep compatibility shims<\/a> until after a LTS release, so that third-party applications can more easily support multiple LTS releases.<\/p>\n<p>Enabling warnings is nice because you see warnings from python or other packages, so you can address whatever problems they&#8217;re warning about, or at least know that they will be an issue in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently updated a Django project from 1.8 to 1.11. In the process, I started turning warnings into errors. Django docs recommend resolving any deprecation warnings with current version, before upgrading to a new version of Django. In this case, I didn&#8217;t start my upgrade work by resolving warnings, but I did run the tests &hellip; <a href=\"https:\/\/library.brown.edu\/create\/digitaltechnologies\/python-django-warnings\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python\/Django warnings<\/span><\/a><\/p>\n","protected":false},"author":110,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10,14],"tags":[],"class_list":["post-408","post","type-post","status-publish","format-standard","hentry","category-bdr","category-programming","category-web"],"_links":{"self":[{"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/posts\/408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":0,"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"wp:attachment":[{"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/library.brown.edu\/create\/digitaltechnologies\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}