From e9b0d70f5d8eb94d72da677846d5dab5b587e945 Mon Sep 17 00:00:00 2001 From: "S.Prymak" Date: Tue, 14 Jan 2014 10:38:49 +0200 Subject: [PATCH] Override HyperlinkedModelSerializerOptions url field name with URL_FIELD_NAME setting --- rest_framework/serializers.py | 4 +++- rest_framework/settings.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 0b5c6a05b..73c407c7b 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -20,6 +20,8 @@ from django.db import models from django.forms import widgets from django.utils.datastructures import SortedDict from rest_framework.compat import get_concrete_model, six +from rest_framework.settings import api_settings + # Note: We do the following so that users of the framework can use this style: # @@ -990,7 +992,7 @@ class HyperlinkedModelSerializerOptions(ModelSerializerOptions): super(HyperlinkedModelSerializerOptions, self).__init__(meta) self.view_name = getattr(meta, 'view_name', None) self.lookup_field = getattr(meta, 'lookup_field', None) - self.url_field_name = getattr(meta, 'url_field_name', 'url') + self.url_field_name = getattr(meta, 'url_field_name', api_settings.URL_FIELD_NAME) class HyperlinkedModelSerializer(ModelSerializer): diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 8abaf1409..ce171d6d4 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -95,6 +95,7 @@ DEFAULTS = { 'URL_FORMAT_OVERRIDE': 'format', 'FORMAT_SUFFIX_KWARG': 'format', + 'URL_FIELD_NAME': 'url', # Input and output formats 'DATE_INPUT_FORMATS': (