Skip to content

Commit a26d633

Browse files
committed
Rename FORMAT_LINKS setting to FORMAT_RELATED_LINKS
1 parent 986df87 commit a26d633

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ any parts of the framework not mentioned in the documentation should generally b
1313
### Added
1414

1515
* Ability for the user to select `included_serializers` to apply when using `BrowsableAPI`, based on available `included_serializers` defined for the current endpoint.
16-
* Ability for the user to format serializer properties in URL segments using the `JSON_API_FORMAT_LINKS` setting.
16+
* Ability for the user to format serializer properties in URL segments using the `JSON_API_FORMAT_RELATED_LINKS` setting.
1717

1818
### Fixed
1919

docs/usage.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ When set to pluralize:
479479

480480
#### Related URL segments
481481

482-
Serializer properties in relationship and related resource URLs may be infected using the `JSON_API_FORMAT_LINKS` setting.
482+
Serializer properties in relationship and related resource URLs may be infected using the `JSON_API_FORMAT_RELATED_LINKS` setting.
483483

484484
``` python
485-
JSON_API_FORMAT_LINKS = 'dasherize'
485+
JSON_API_FORMAT_RELATED_LINKS = 'dasherize'
486486
```
487487

488488
For example, with a serializer property `created_by` and with `'dasherize'` formatting:
@@ -513,7 +513,7 @@ For example, with a serializer property `created_by` and with `'dasherize'` form
513513
}
514514
```
515515

516-
The relationship name is formatted by the `JSON_API_FORMAT_FIELD_NAMES` setting, but the URL segments are formatted by the `JSON_API_FORMAT_LINKS` setting.
516+
The relationship name is formatted by the `JSON_API_FORMAT_FIELD_NAMES` setting, but the URL segments are formatted by the `JSON_API_FORMAT_RELATED_LINKS` setting.
517517

518518
### Related fields
519519

rest_framework_json_api/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
DEFAULTS = {
1313
"FORMAT_FIELD_NAMES": False,
1414
"FORMAT_TYPES": False,
15-
"FORMAT_LINKS": False,
15+
"FORMAT_RELATED_LINKS": False,
1616
"PLURALIZE_TYPES": False,
1717
"UNIFORM_EXCEPTIONS": False,
1818
}

rest_framework_json_api/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ def format_resource_type(value, format_type=None, pluralize=None):
151151
def format_link_segment(value, format_type=None):
152152
"""
153153
Takes a string value and returns it with formatted keys as set in `format_type`
154-
or `JSON_API_FORMAT_LINKS`.
154+
or `JSON_API_FORMAT_RELATED_LINKS`.
155155
156156
:format_type: Either 'dasherize', 'camelize', 'capitalize' or 'underscore'
157157
"""
158158
if format_type is None:
159-
format_type = json_api_settings.FORMAT_LINKS
159+
format_type = json_api_settings.FORMAT_RELATED_LINKS
160160

161161
return format_value(value, format_type)
162162

tests/test_relations.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@pytest.mark.urls(__name__)
1212
@pytest.mark.parametrize(
13-
"format_links,expected_url_segment",
13+
"format_related_links,expected_url_segment",
1414
[
1515
(None, "relatedField_name"),
1616
("dasherize", "related-field-name"),
@@ -19,10 +19,10 @@
1919
("underscore", "related_field_name"),
2020
],
2121
)
22-
def test_relationship_urls_respect_format_links(
23-
settings, format_links, expected_url_segment
22+
def test_relationship_urls_respect_format_related_links_setting(
23+
settings, format_related_links, expected_url_segment
2424
):
25-
settings.JSON_API_FORMAT_LINKS = format_links
25+
settings.JSON_API_FORMAT_RELATED_LINKS = format_related_links
2626

2727
model = BasicModel(text="Some text")
2828

tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def test_format_field_names(settings, format_type, output):
209209
],
210210
)
211211
def test_format_field_segment(settings, format_type, output):
212-
settings.JSON_API_FORMAT_LINKS = format_type
212+
settings.JSON_API_FORMAT_RELATED_LINKS = format_type
213213
assert format_link_segment("first_Name") == output
214214

215215

0 commit comments

Comments
 (0)