File: Utils-Switch-import-depend-on-Django-version.patch

package info (click to toggle)
django-graphene 2.15.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,668 kB
  • sloc: javascript: 24,625; python: 8,198; makefile: 231; sh: 4
file content (29 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Wed, 13 Jul 2022 21:29:45 +0200
Subject: Utils: Switch import depend on Django version

This patching isn't needed anymore within version 3.0.0.

Forwarded: https://github.com/graphql-python/graphene-django/issues/1284
---
 graphene_django/utils/utils.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/graphene_django/utils/utils.py b/graphene_django/utils/utils.py
index b1c9a7d..29752d0 100644
--- a/graphene_django/utils/utils.py
+++ b/graphene_django/utils/utils.py
@@ -3,7 +3,12 @@ import inspect
 import six
 from django.db import connection, models, transaction
 from django.db.models.manager import Manager
-from django.utils.encoding import force_text
+import django
+if int(django.get_version()[0]) > 3:
+    from django.utils.encoding import force_str
+    django.utils.encoding.force_text = force_str
+else:
+    from django.utils.encoding import force_text
 from django.utils.functional import Promise
 
 from graphene.utils.str_converters import to_camel_case