Browse Source

Closes #1706: Added deprecation warning for Python 2

Jeremy Stretch 7 years ago
parent
commit
5c13382071
1 changed files with 9 additions and 0 deletions
  1. 9 0
      netbox/netbox/settings.py

+ 9 - 0
netbox/netbox/settings.py

@@ -1,6 +1,8 @@
 import logging
 import os
 import socket
+import sys
+import warnings
 
 from django.contrib.messages import constants as messages
 from django.core.exceptions import ImproperlyConfigured
@@ -12,6 +14,13 @@ except ImportError:
         "Configuration file is not present. Please define netbox/netbox/configuration.py per the documentation."
     )
 
+# Raise a deprecation warning for Python 2.x
+if sys.version_info[0] < 3:
+    warnings.warn(
+        "Support for Python 2 will be removed in NetBox v2.5. Please consider migration to Python 3 at your earliest "
+        "opportunity. Guidance is available in the documentation at http://netbox.readthedocs.io/.",
+        DeprecationWarning
+    )
 
 VERSION = '2.2.6-dev'