Skip to content

Commit

Permalink
Upgraded support for Django 4
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinkoz committed Feb 10, 2022
1 parent 970c730 commit fe34df1
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code.yaml
Expand Up @@ -14,8 +14,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
django-version: ["~=3.1.0", "~=3.2.0"]
python-version: ["3.8", "3.9", "3.10"]
django-version: ["~=3.1.0", "~=3.2.0", "~=4.0.0"]
services:
postgres:
image: postgres:latest
Expand Down
4 changes: 2 additions & 2 deletions django_pgschemas/contrib/channels2/router.py
@@ -1,7 +1,7 @@
from channels.routing import ProtocolTypeRouter, URLRouter
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.module_loading import import_string

from ...schema import SchemaDescriptor
Expand Down Expand Up @@ -36,7 +36,7 @@ def get_tenant_scope(self, scope):
"""
Get tenant and websockets urlconf based on scope host.
"""
hostname = force_text(dict(scope["headers"]).get(b"host", b""))
hostname = force_str(dict(scope["headers"]).get(b"host", b""))
hostname = remove_www(hostname.split(":")[0])

tenant = None
Expand Down
4 changes: 2 additions & 2 deletions django_pgschemas/contrib/channels3/router.py
Expand Up @@ -2,7 +2,7 @@
from channels.routing import ProtocolTypeRouter, URLRouter
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.module_loading import import_string

from ...schema import SchemaDescriptor
Expand Down Expand Up @@ -38,7 +38,7 @@ def get_tenant_scope(self, scope):
"""
Get tenant and websockets urlconf based on scope host.
"""
hostname = force_text(dict(scope["headers"]).get(b"host", b""))
hostname = force_str(dict(scope["headers"]).get(b"host", b""))
hostname = remove_www(hostname.split(":")[0])

tenant = None
Expand Down
6 changes: 3 additions & 3 deletions django_pgschemas/postgresql_backend/introspection.py
@@ -1,5 +1,5 @@
from django.db.backends.base.introspection import FieldInfo, TableInfo
from django.utils.encoding import force_text
from django.utils.encoding import force_str

from . import _constraints
from .settings import base_backend, original_backend
Expand Down Expand Up @@ -63,9 +63,9 @@ def get_table_description(self, cursor, table_name):
return [
FieldInfo(
*(
(force_text(line[0]),)
(force_str(line[0]),)
+ line[1:6]
+ (field_map[force_text(line[0])][0] == "YES", field_map[force_text(line[0])][1])
+ (field_map[force_str(line[0])][0] == "YES", field_map[force_str(line[0])][1])
)
)
for line in cursor.description
Expand Down
8 changes: 4 additions & 4 deletions django_pgschemas/signals.py
Expand Up @@ -3,16 +3,16 @@

from .utils import get_tenant_model, schema_exists

schema_activate = Signal(providing_args=["schema"])
schema_activate = Signal()
schema_activate.__doc__ = "Sent after a schema has been activated"

dynamic_tenant_needs_sync = Signal(providing_args=["tenant"])
dynamic_tenant_needs_sync = Signal()
dynamic_tenant_needs_sync.__doc__ = "Sent when a schema from a dynamic tenant needs to be synced"

dynamic_tenant_post_sync = Signal(providing_args=["tenant"])
dynamic_tenant_post_sync = Signal()
dynamic_tenant_post_sync.__doc__ = "Sent after a tenant has been saved, its schema created and synced"

dynamic_tenant_pre_drop = Signal(providing_args=["tenant"])
dynamic_tenant_pre_drop = Signal()
dynamic_tenant_pre_drop.__doc__ = "Sent when a schema from a dynamic tenant is about to be dropped"


Expand Down
183 changes: 72 additions & 111 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Expand Up @@ -13,11 +13,12 @@ classifiers = [
"Framework :: Django",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
]

[tool.poetry.dependencies]
python = "^3.7"
django = ">=3.1,<4.0"
python = "^3.8"
django = ">=3.1,<4.1"
psycopg2 = "^2.9.3"

[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit fe34df1

Please sign in to comment.