diff options
| author | Alen Mujezinovic | 2012-01-19 15:52:26 +0000 |
|---|---|---|
| committer | Alen Mujezinovic | 2012-01-19 15:52:26 +0000 |
| commit | ec5badf739908f5c26691a47955d79c42d5a39df (patch) | |
| tree | aa86162ba4bea11b8e20dcfe2d0ad0b8308efa4b /djangorestframework/resources.py | |
| parent | 167dce008cc967755a2a433b710207a7ae7315af (diff) | |
| download | django-rest-framework-ec5badf739908f5c26691a47955d79c42d5a39df.tar.bz2 | |
Renamed `unknown_form_fields` to `allow_unknown_form_fields`
Diffstat (limited to 'djangorestframework/resources.py')
| -rw-r--r-- | djangorestframework/resources.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index de369948..2e855021 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -78,7 +78,7 @@ class FormResource(Resource): This can be overridden by a :attr:`form` attribute on the :class:`views.View`. """ - unknown_form_fields = False + allow_unknown_form_fields = False """ Flag to check for unknown fields when validating a form. If set to false and we receive request data that is not expected by the form it raises an @@ -93,7 +93,7 @@ class FormResource(Resource): Raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure. Validation is standard form validation, with an additional constraint that *no extra unknown fields* may be supplied - if :attr:`self.unknown_form_fields` is ``False``. + if :attr:`self.allow_unknown_form_fields` is ``False``. On failure the :exc:`response.ErrorResponse` content is a dict which may contain :obj:`'errors'` and :obj:`'field-errors'` keys. If the :obj:`'errors'` key exists it is a list of strings of non-field errors. @@ -141,7 +141,7 @@ class FormResource(Resource): unknown_fields = unknown_fields - set(('csrfmiddlewaretoken', '_accept', '_method')) # TODO: Ugh. # Check using both regular validation, and our stricter no additional fields rule - if bound_form.is_valid() and (self.unknown_form_fields or not unknown_fields): + if bound_form.is_valid() and (self.allow_unknown_form_fields or not unknown_fields): # Validation succeeded... cleaned_data = bound_form.cleaned_data @@ -398,7 +398,7 @@ class ModelResource(FormResource): """ model_fields = set(field.name for field in self.model._meta.fields) - if fields: + if model_fields: return model_fields & set(as_tuple(self.fields)) return model_fields - set(as_tuple(self.exclude)) |
