use double quotes in user messages

This commit is contained in:
Craig Blaszczyk 2015-01-07 12:33:37 +00:00
parent 662a907bdf
commit 9a4267049b
5 changed files with 7 additions and 7 deletions

View File

@ -95,7 +95,7 @@ class NotFound(APIException):
class MethodNotAllowed(APIException): class MethodNotAllowed(APIException):
status_code = status.HTTP_405_METHOD_NOT_ALLOWED status_code = status.HTTP_405_METHOD_NOT_ALLOWED
default_detail = _("Method '{method}' not allowed.") default_detail = _("Method \"{method}\" not allowed.")
def __init__(self, method, detail=None): def __init__(self, method, detail=None):
if detail is not None: if detail is not None:
@ -118,7 +118,7 @@ class NotAcceptable(APIException):
class UnsupportedMediaType(APIException): class UnsupportedMediaType(APIException):
status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
default_detail = _("Unsupported media type '{media_type}' in request.") default_detail = _("Unsupported media type \"{media_type}\" in request.")
def __init__(self, media_type, detail=None): def __init__(self, media_type, detail=None):
if detail is not None: if detail is not None:

View File

@ -612,7 +612,7 @@ class RegexField(CharField):
class SlugField(CharField): class SlugField(CharField):
default_error_messages = { default_error_messages = {
'invalid': _("Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.") 'invalid': _("Enter a valid \"slug\" consisting of letters, numbers, underscores or hyphens.")
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):

View File

@ -120,12 +120,12 @@ class GenericAPIView(views.APIView):
if page == 'last': if page == 'last':
page_number = paginator.num_pages page_number = paginator.num_pages
else: else:
raise NotFound(_("Choose a valid page number. Page numbers must be a whole number, or must be the string 'last'.")) raise NotFound(_("Choose a valid page number. Page numbers must be a whole number, or must be the string \"last\"."))
try: try:
page = paginator.page(page_number) page = paginator.page(page_number)
except InvalidPage as exc: except InvalidPage as exc:
error_format = _("Invalid page ({page_number}): {message}.") error_format = _("Invalid page \"{page_number}\": {message}.")
raise NotFound(error_format.format( raise NotFound(error_format.format(
page_number=page_number, message=six.text_type(exc) page_number=page_number, message=six.text_type(exc)
)) ))

View File

@ -129,7 +129,7 @@ class StringRelatedField(RelatedField):
class PrimaryKeyRelatedField(RelatedField): class PrimaryKeyRelatedField(RelatedField):
default_error_messages = { default_error_messages = {
'required': _("This field is required."), 'required': _("This field is required."),
'does_not_exist': _("Invalid pk '{pk_value}' - object does not exist."), 'does_not_exist': _("Invalid pk \"{pk_value}\" - object does not exist."),
'incorrect_type': _("Incorrect type. Expected pk value, received {data_type}."), 'incorrect_type': _("Incorrect type. Expected pk value, received {data_type}."),
} }

View File

@ -36,7 +36,7 @@ class AcceptHeaderVersioning(BaseVersioning):
Host: example.com Host: example.com
Accept: application/json; version=1.0 Accept: application/json; version=1.0
""" """
invalid_version_message = _("Invalid version in 'Accept' header.") invalid_version_message = _("Invalid version in \"Accept\" header.")
def determine_version(self, request, *args, **kwargs): def determine_version(self, request, *args, **kwargs):
media_type = _MediaType(request.accepted_media_type) media_type = _MediaType(request.accepted_media_type)