Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
a90ba2bc
Commit
a90ba2bc
authored
Dec 31, 2014
by
Craig Blaszczyk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update error messages for language and consistency
parent
faf76a4b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
28 deletions
+28
-28
rest_framework/exceptions.py
+2
-2
rest_framework/fields.py
+8
-9
rest_framework/generics.py
+1
-1
rest_framework/locale/en_US/LC_MESSAGES/django.po
+17
-16
No files found.
rest_framework/exceptions.py
View file @
a90ba2bc
...
...
@@ -36,7 +36,7 @@ class APIException(Exception):
Subclasses should provide `.status_code` and `.default_detail` properties.
"""
status_code
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
default_detail
=
_
(
'A server error occurred'
)
default_detail
=
_
(
'A server error occurred
.
'
)
def
__init__
(
self
,
detail
=
None
):
if
detail
is
not
None
:
...
...
@@ -107,7 +107,7 @@ class MethodNotAllowed(APIException):
class
NotAcceptable
(
APIException
):
status_code
=
status
.
HTTP_406_NOT_ACCEPTABLE
default_detail
=
_
(
'Could not satisfy the request Accept header'
)
default_detail
=
_
(
'Could not satisfy the request Accept header
.
'
)
def
__init__
(
self
,
detail
=
None
,
available_renderers
=
None
):
if
detail
is
not
None
:
...
...
rest_framework/fields.py
View file @
a90ba2bc
...
...
@@ -640,7 +640,7 @@ class IntegerField(Field):
'invalid'
:
_
(
'A valid integer is required.'
),
'max_value'
:
_
(
'Ensure this value is less than or equal to {max_value}.'
),
'min_value'
:
_
(
'Ensure this value is greater than or equal to {min_value}.'
),
'max_string_length'
:
_
(
'String value too large'
)
'max_string_length'
:
_
(
'String value too large
.
'
)
}
MAX_STRING_LENGTH
=
1000
# Guard against malicious string inputs.
...
...
@@ -674,7 +674,7 @@ class FloatField(Field):
'invalid'
:
_
(
"A valid number is required."
),
'max_value'
:
_
(
'Ensure this value is less than or equal to {max_value}.'
),
'min_value'
:
_
(
'Ensure this value is greater than or equal to {min_value}.'
),
'max_string_length'
:
_
(
'String value too large'
)
'max_string_length'
:
_
(
'String value too large
.
'
)
}
MAX_STRING_LENGTH
=
1000
# Guard against malicious string inputs.
...
...
@@ -710,7 +710,7 @@ class DecimalField(Field):
'max_digits'
:
_
(
'Ensure that there are no more than {max_digits} digits in total.'
),
'max_decimal_places'
:
_
(
'Ensure that there are no more than {max_decimal_places} decimal places.'
),
'max_whole_digits'
:
_
(
'Ensure that there are no more than {max_whole_digits} digits before the decimal point.'
),
'max_string_length'
:
_
(
'String value too large'
)
'max_string_length'
:
_
(
'String value too large
.
'
)
}
MAX_STRING_LENGTH
=
1000
# Guard against malicious string inputs.
...
...
@@ -793,7 +793,7 @@ class DecimalField(Field):
class
DateTimeField
(
Field
):
default_error_messages
=
{
'invalid'
:
_
(
'Datetime has wrong format. Use one of these formats instead: {format}'
),
'invalid'
:
_
(
'Datetime has wrong format. Use one of these formats instead: {format}
.
'
),
'date'
:
_
(
'Expected a datetime but got a date.'
),
}
format
=
api_settings
.
DATETIME_FORMAT
...
...
@@ -858,7 +858,7 @@ class DateTimeField(Field):
class
DateField
(
Field
):
default_error_messages
=
{
'invalid'
:
_
(
'Date has wrong format. Use one of these formats instead: {format}'
),
'invalid'
:
_
(
'Date has wrong format. Use one of these formats instead: {format}
.
'
),
'datetime'
:
_
(
'Expected a date but got a datetime.'
),
}
format
=
api_settings
.
DATE_FORMAT
...
...
@@ -916,7 +916,7 @@ class DateField(Field):
class
TimeField
(
Field
):
default_error_messages
=
{
'invalid'
:
_
(
'Time has wrong format. Use one of these formats instead: {format}'
),
'invalid'
:
_
(
'Time has wrong format. Use one of these formats instead: {format}
.
'
),
}
format
=
api_settings
.
TIME_FORMAT
input_formats
=
api_settings
.
TIME_INPUT_FORMATS
...
...
@@ -1093,8 +1093,7 @@ class FileField(Field):
class
ImageField
(
FileField
):
default_error_messages
=
{
'invalid_image'
:
_
(
'Upload a valid image. The file you uploaded was either not an '
'image or a corrupted image.'
'Upload a valid image. The file you uploaded was either not an image or a corrupted image.'
),
}
...
...
@@ -1119,7 +1118,7 @@ class ListField(Field):
child
=
None
initial
=
[]
default_error_messages
=
{
'not_a_list'
:
_
(
'Expected a list of items but got type `{input_type}`'
)
'not_a_list'
:
_
(
'Expected a list of items but got type `{input_type}`
.
'
)
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
rest_framework/generics.py
View file @
a90ba2bc
...
...
@@ -119,7 +119,7 @@ class GenericAPIView(views.APIView):
if
page
==
'last'
:
page_number
=
paginator
.
num_pages
else
:
raise
Http404
(
_
(
"
Page is not 'last', and cannot be converted to an int
."
))
raise
Http404
(
_
(
"
Choose a valid page number. Page numbers must be a whole number, or must be the string 'last'
."
))
try
:
page
=
paginator
.
page
(
page_number
)
except
InvalidPage
as
exc
:
...
...
rest_framework/locale/en_US/LC_MESSAGES/django.po
View file @
a90ba2bc
...
...
@@ -2,13 +2,13 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-12-31 1
2:48
+0000\n"
"POT-Creation-Date: 2014-12-31 1
3:02
+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -30,7 +30,7 @@ msgid "Must include \"username\" and \"password\""
msgstr ""
#: rest_framework/exceptions.py:39
msgid "A server error occurred"
msgid "A server error occurred
.
"
msgstr ""
#: rest_framework/exceptions.py:74
...
...
@@ -55,7 +55,7 @@ msgid "Method '%s' not allowed."
msgstr ""
#: rest_framework/exceptions.py:105
msgid "Could not satisfy the request Accept header"
msgid "Could not satisfy the request Accept header
.
"
msgstr ""
#: rest_framework/exceptions.py:117
...
...
@@ -92,7 +92,7 @@ msgstr ""
msgid "This field may not be blank."
msgstr ""
#: rest_framework/fields.py:548 rest_framework/fields.py:12
50
#: rest_framework/fields.py:548 rest_framework/fields.py:12
49
msgid "Ensure this field has no more than {max_length} characters."
msgstr ""
...
...
@@ -133,7 +133,7 @@ msgstr ""
#: rest_framework/fields.py:640 rest_framework/fields.py:674
#: rest_framework/fields.py:710
msgid "String value too large"
msgid "String value too large
.
"
msgstr ""
#: rest_framework/fields.py:671 rest_framework/fields.py:704
...
...
@@ -155,7 +155,7 @@ msgid ""
msgstr ""
#: rest_framework/fields.py:793
msgid "Datetime has wrong format. Use one of these formats instead: {format}"
msgid "Datetime has wrong format. Use one of these formats instead: {format}
.
"
msgstr ""
#: rest_framework/fields.py:794
...
...
@@ -163,7 +163,7 @@ msgid "Expected a datetime but got a date."
msgstr ""
#: rest_framework/fields.py:858
msgid "Date has wrong format. Use one of these formats instead: {format}"
msgid "Date has wrong format. Use one of these formats instead: {format}
.
"
msgstr ""
#: rest_framework/fields.py:859
...
...
@@ -171,14 +171,15 @@ msgid "Expected a date but got a datetime."
msgstr ""
#: rest_framework/fields.py:916
msgid "Time has wrong format. Use one of these formats instead: {format}"
msgid "Time has wrong format. Use one of these formats instead: {format}
.
"
msgstr ""
#: rest_framework/fields.py:972 rest_framework/fields.py:1016
msgid "`{input}` is not a valid choice."
msgstr ""
#: rest_framework/fields.py:1017 rest_framework/serializers.py:474
#: rest_framework/fields.py:1017 rest_framework/fields.py:1118
#: rest_framework/serializers.py:474
msgid "Expected a list of items but got type `{input_type}`."
msgstr ""
...
...
@@ -204,15 +205,15 @@ msgid ""
msgstr ""
#: rest_framework/fields.py:1093
msgid "Upload a valid image. The file you uploaded was either not an "
msgstr ""
#: rest_framework/fields.py:1119
msgid "Expected a list of items but got type `{input_type}`"
msgid ""
"Upload a valid image. The file you uploaded was either not an image or a "
"corrupted image."
msgstr ""
#: rest_framework/generics.py:122
msgid "Page is not 'last', and cannot be converted to an int."
msgid ""
"Choose a valid page number. Page numbers must be a whole number, or must be "
"the string 'last'."
msgstr ""
#: rest_framework/generics.py:126
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment