Sfoglia il codice sorgente

12237 update to Django 4.2 / psycopg3 (#12916)

* 12237 upgrade django and psycopg

* 12237 add migration

* 12237 rename migration

* 12237 update requirements

* 12237 fix migration

* Update base requirements

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
Arthur Hanson 2 anni fa
parent
commit
69b818ed33

+ 3 - 3
base_requirements.txt

@@ -8,7 +8,7 @@ boto3
 
 # The Python web framework on which NetBox is built
 # https://docs.djangoproject.com/en/stable/releases/
-Django<4.2
+Django<5.0
 
 # Django middleware which permits cross-domain API requests
 # https://github.com/adamchainz/django-cors-headers/blob/main/CHANGELOG.rst
@@ -121,8 +121,8 @@ netaddr
 Pillow
 
 # PostgreSQL database adapter for Python
-# https://www.psycopg.org/docs/news.html
-psycopg2-binary
+# https://github.com/psycopg/psycopg/blob/master/docs/news.rst
+psycopg[binary,pool]
 
 # YAML rendering library
 # https://github.com/yaml/pyyaml/blob/master/CHANGES

+ 3 - 1
netbox/core/models/data.py

@@ -290,8 +290,10 @@ class DataFile(models.Model):
 
     @property
     def data_as_string(self):
+        if not self.data:
+            return None
         try:
-            return self.data.tobytes().decode('utf-8')
+            return bytes(self.data, 'utf-8')
         except UnicodeDecodeError:
             return None
 

+ 17 - 0
netbox/extras/migrations/0093_tagged_item_indexes.py

@@ -0,0 +1,17 @@
+# Generated by Django 4.2.2 on 2023-06-14 23:26
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ('extras', '0093_configrevision_ordering'),
+    ]
+
+    operations = [
+        migrations.RenameIndex(
+            model_name='taggeditem',
+            new_name='extras_tagg_content_717743_idx',
+            old_fields=('content_type', 'object_id'),
+        ),
+    ]

+ 1 - 3
netbox/extras/models/tags.py

@@ -61,6 +61,4 @@ class TaggedItem(GenericTaggedItemBase):
     )
 
     class Meta:
-        index_together = (
-            ("content_type", "object_id")
-        )
+        indexes = [models.Index(fields=["content_type", "object_id"])]

+ 2 - 2
requirements.txt

@@ -1,6 +1,6 @@
 bleach==6.0.0
 boto3==1.26.156
-Django==4.1.9
+Django==4.2.2
 django-cors-headers==4.1.0
 django-debug-toolbar==4.1.0
 django-filter==23.2
@@ -27,7 +27,7 @@ mkdocs-material==9.1.16
 mkdocstrings[python-legacy]==0.22.0
 netaddr==0.8.0
 Pillow==9.5.0
-psycopg2-binary==2.9.6
+psycopg[binary,pool]==3.1.9
 PyYAML==6.0
 sentry-sdk==1.25.1
 social-auth-app-django==5.2.0