mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 05:47:38 -02:30
Fix Django 3.1 deprecation removal problems
- FieldDoesNotExist now has to be imported from django.core.exceptions - Django docs specifically say not to import django.conf.global_settings, which now has the side-effect of triggering one of the check errors
This commit is contained in:
@@ -7,10 +7,9 @@ import json
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.core.exceptions import FieldError, ValidationError
|
from django.core.exceptions import FieldError, ValidationError, FieldDoesNotExist
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q, CharField, IntegerField, BooleanField
|
from django.db.models import Q, CharField, IntegerField, BooleanField
|
||||||
from django.db.models.fields import FieldDoesNotExist
|
|
||||||
from django.db.models.fields.related import ForeignObjectRel, ManyToManyField, ForeignKey
|
from django.db.models.fields.related import ForeignObjectRel, ManyToManyField, ForeignKey
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ import urllib.parse
|
|||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
from django.core.exceptions import FieldDoesNotExist
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.models.fields import FieldDoesNotExist
|
|
||||||
from django.db.models.fields.related import OneToOneRel
|
from django.db.models.fields.related import OneToOneRel
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.contrib.contenttypes.models import ContentType
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.contrib.auth import views as auth_views
|
|
||||||
|
|
||||||
# Django REST Framework
|
# Django REST Framework
|
||||||
from rest_framework.exceptions import PermissionDenied, AuthenticationFailed, ParseError, NotAcceptable, UnsupportedMediaType
|
from rest_framework.exceptions import PermissionDenied, AuthenticationFailed, ParseError, NotAcceptable, UnsupportedMediaType
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
# Django
|
||||||
|
from django.core.exceptions import FieldDoesNotExist
|
||||||
|
|
||||||
from rest_framework.exceptions import PermissionDenied, ParseError
|
from rest_framework.exceptions import PermissionDenied, ParseError
|
||||||
|
|
||||||
from awx.api.filters import FieldLookupBackend, OrderByBackend, get_field_from_path
|
from awx.api.filters import FieldLookupBackend, OrderByBackend, get_field_from_path
|
||||||
from awx.main.models import (
|
from awx.main.models import (
|
||||||
AdHocCommand,
|
AdHocCommand,
|
||||||
@@ -22,9 +26,6 @@ from awx.main.models import (
|
|||||||
from awx.main.models.oauth import OAuth2Application
|
from awx.main.models.oauth import OAuth2Application
|
||||||
from awx.main.models.jobs import JobOptions
|
from awx.main.models.jobs import JobOptions
|
||||||
|
|
||||||
# Django
|
|
||||||
from django.db.models.fields import FieldDoesNotExist
|
|
||||||
|
|
||||||
|
|
||||||
def test_related():
|
def test_related():
|
||||||
field_lookup = FieldLookupBackend()
|
field_lookup = FieldLookupBackend()
|
||||||
|
|||||||
@@ -7,14 +7,6 @@ import re # noqa
|
|||||||
import sys
|
import sys
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
# global settings
|
|
||||||
from django.conf import global_settings
|
|
||||||
|
|
||||||
# Update this module's local settings from the global settings module.
|
|
||||||
this_module = sys.modules[__name__]
|
|
||||||
for setting in dir(global_settings):
|
|
||||||
if setting == setting.upper():
|
|
||||||
setattr(this_module, setting, getattr(global_settings, setting))
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
@@ -451,7 +443,7 @@ CACHES = {'default': {'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': 'u
|
|||||||
# Social Auth configuration.
|
# Social Auth configuration.
|
||||||
SOCIAL_AUTH_STRATEGY = 'social_django.strategy.DjangoStrategy'
|
SOCIAL_AUTH_STRATEGY = 'social_django.strategy.DjangoStrategy'
|
||||||
SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage'
|
SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage'
|
||||||
SOCIAL_AUTH_USER_MODEL = AUTH_USER_MODEL # noqa
|
SOCIAL_AUTH_USER_MODEL = 'auth.User'
|
||||||
|
|
||||||
_SOCIAL_AUTH_PIPELINE_BASE = (
|
_SOCIAL_AUTH_PIPELINE_BASE = (
|
||||||
'social_core.pipeline.social_auth.social_details',
|
'social_core.pipeline.social_auth.social_details',
|
||||||
|
|||||||
Reference in New Issue
Block a user