Skip to content

Commit 7920058

Browse files
author
Omer Katz
committed
Cached the field's root and context property.
1 parent 1b53e80 commit 7920058

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rest_framework/fields.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from django.utils import six, timezone
1818
from django.utils.dateparse import parse_date, parse_datetime, parse_time
1919
from django.utils.encoding import is_protected_type, smart_text
20+
from django.utils.functional import cached_property
2021
from django.utils.ipv6 import clean_ipv6_address
2122
from django.utils.translation import ugettext_lazy as _
2223

@@ -522,7 +523,7 @@ def fail(self, key, **kwargs):
522523
message_string = msg.format(**kwargs)
523524
raise ValidationError(message_string)
524525

525-
@property
526+
@cached_property
526527
def root(self):
527528
"""
528529
Returns the top-level serializer for this field.
@@ -532,7 +533,7 @@ def root(self):
532533
root = root.parent
533534
return root
534535

535-
@property
536+
@cached_property
536537
def context(self):
537538
"""
538539
Returns the context as passed to the root serializer on initialization.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy