File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change 33from django .db .models .fields import AutoField
44from django .utils .functional import cached_property
55
6- from .objectid_mixin import ObjectIdMixin
6+ from .objectid import ObjectIdMixin
77
88
99class ObjectIdAutoField (ObjectIdMixin , AutoField ):
Original file line number Diff line number Diff line change 22from bson .errors import InvalidId
33from django .core import exceptions
44from django .db .models .fields import Field
5+ from django .utils .translation import gettext_lazy as _
56
6- from .objectid_mixin import ObjectIdMixin
7+
8+ class ObjectIdMixin :
9+ default_error_messages = {
10+ "invalid" : _ ("“%(value)s” value must be an Object Id." ),
11+ }
12+ description = _ ("Object Id" )
13+
14+ def db_type (self , connection ):
15+ return "objectId"
16+
17+ def rel_db_type (self , connection ):
18+ return "objectId"
719
820
921class ObjectIdField (ObjectIdMixin , Field ):
1022 def get_internal_type (self ):
1123 return "ObjectIdField"
1224
1325 def to_python (self , value ):
26+ if value is None :
27+ return value
1428 try :
1529 return ObjectId (value )
1630 except (TypeError , InvalidId ):
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments