Remove Field(name='...') which was deprecated when db_field was introduced a while ago

This commit is contained in:
Bastien Gérard 2020-03-17 21:26:41 +01:00
parent 00ae6298d4
commit 8eb51790b5
2 changed files with 2 additions and 6 deletions

View File

@ -10,6 +10,7 @@ Development
- Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264
- Add support for the `elemMatch` projection operator in .fields() (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267
- DictField validate failed without default connection (bug introduced in 0.19.0) #2239
- Remove name parameter in Field constructor e.g `StringField(name="...")`, it was deprecated a while ago in favor of db_field
Changes in 0.19.1
=================

View File

@ -36,7 +36,6 @@ class BaseField(object):
def __init__(
self,
db_field=None,
name=None,
required=False,
default=None,
unique=False,
@ -51,7 +50,6 @@ class BaseField(object):
"""
:param db_field: The database field to store this field in
(defaults to the name of the field)
:param name: Deprecated - use db_field
:param required: If the field is required. Whether it has to have a
value or not. Defaults to False.
:param default: (optional) The default value for this field if no value
@ -75,11 +73,8 @@ class BaseField(object):
existing attributes. Common metadata includes `verbose_name` and
`help_text`.
"""
self.db_field = (db_field or name) if not primary_key else "_id"
self.db_field = db_field if not primary_key else "_id"
if name:
msg = 'Field\'s "name" attribute deprecated in favour of "db_field"'
warnings.warn(msg, DeprecationWarning)
self.required = required or primary_key
self.default = default
self.unique = bool(unique or unique_with)