summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/fields
diff options
context:
space:
mode:
authorsage <laymonage@gmail.com>2019-10-17 11:36:39 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-17 12:30:29 +0200
commit6f82df69efa372fb4bddf272fff577850a09f1dc (patch)
tree719b621431e229fbc02bb2a70183a2a32d344d27 /django/contrib/postgres/fields
parent187a64608d2a207dfc12fdd6816526e9550069b7 (diff)
Refs #12990 -- Moved CheckFieldDefaultMixin to the django.db.models.fields.mixins.
Diffstat (limited to 'django/contrib/postgres/fields')
-rw-r--r--django/contrib/postgres/fields/array.py2
-rw-r--r--django/contrib/postgres/fields/hstore.py3
-rw-r--r--django/contrib/postgres/fields/jsonb.py3
-rw-r--r--django/contrib/postgres/fields/mixins.py29
4 files changed, 3 insertions, 34 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py
index 1180795e8f..f8ce7911ef 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -5,11 +5,11 @@ from django.contrib.postgres.forms import SimpleArrayField
from django.contrib.postgres.validators import ArrayMaxLengthValidator
from django.core import checks, exceptions
from django.db.models import Field, IntegerField, Transform
+from django.db.models.fields.mixins import CheckFieldDefaultMixin
from django.db.models.lookups import Exact, In
from django.utils.translation import gettext_lazy as _
from ..utils import prefix_validation_error
-from .mixins import CheckFieldDefaultMixin
from .utils import AttributeSetter
__all__ = ['ArrayField']
diff --git a/django/contrib/postgres/fields/hstore.py b/django/contrib/postgres/fields/hstore.py
index 0889f600a5..2ec5766041 100644
--- a/django/contrib/postgres/fields/hstore.py
+++ b/django/contrib/postgres/fields/hstore.py
@@ -4,10 +4,9 @@ from django.contrib.postgres import forms, lookups
from django.contrib.postgres.fields.array import ArrayField
from django.core import exceptions
from django.db.models import Field, TextField, Transform
+from django.db.models.fields.mixins import CheckFieldDefaultMixin
from django.utils.translation import gettext_lazy as _
-from .mixins import CheckFieldDefaultMixin
-
__all__ = ['HStoreField']
diff --git a/django/contrib/postgres/fields/jsonb.py b/django/contrib/postgres/fields/jsonb.py
index 30c48a6018..c402dd19d8 100644
--- a/django/contrib/postgres/fields/jsonb.py
+++ b/django/contrib/postgres/fields/jsonb.py
@@ -7,10 +7,9 @@ from django.core import exceptions
from django.db.models import (
Field, TextField, Transform, lookups as builtin_lookups,
)
+from django.db.models.fields.mixins import CheckFieldDefaultMixin
from django.utils.translation import gettext_lazy as _
-from .mixins import CheckFieldDefaultMixin
-
__all__ = ['JSONField']
diff --git a/django/contrib/postgres/fields/mixins.py b/django/contrib/postgres/fields/mixins.py
deleted file mode 100644
index 254b80c4a2..0000000000
--- a/django/contrib/postgres/fields/mixins.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from django.core import checks
-
-
-class CheckFieldDefaultMixin:
- _default_hint = ('<valid default>', '<invalid default>')
-
- def _check_default(self):
- if self.has_default() and self.default is not None and not callable(self.default):
- return [
- checks.Warning(
- "%s default should be a callable instead of an instance so "
- "that it's not shared between all field instances." % (
- self.__class__.__name__,
- ),
- hint=(
- 'Use a callable instead, e.g., use `%s` instead of '
- '`%s`.' % self._default_hint
- ),
- obj=self,
- id='postgres.E003',
- )
- ]
- else:
- return []
-
- def check(self, **kwargs):
- errors = super().check(**kwargs)
- errors.extend(self._check_default())
- return errors