Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinValueValidator on models.DateField causes TypeError #2369

bufke opened this issue Dec 31, 2014 · 1 comment

MinValueValidator on models.DateField causes TypeError #2369

bufke opened this issue Dec 31, 2014 · 1 comment


Copy link

bufke commented Dec 31, 2014

Create a model field like
date = models.DateField(validators=[MinValueValidator(,1,1))])

Reference the field in a serializer and modelviewset.

  File "/usr/local/lib/python2.7/dist-packages/django/template/", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 59, in rendered_content
    ret = renderer.render(, media_type, context)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 733, in render
    context = self.get_context(data, accepted_media_type, renderer_context)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 683, in get_context
    raw_data_post_form = self.get_raw_data_form(data, view, 'POST', request)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 633, in get_raw_data_form
    content = renderer.render(, accepted, context)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 457, in data
    ret = super(Serializer, self).data
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 216, in data
    self._data = self.get_initial()
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 343, in get_initial
    for field in self.fields.values()
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 312, in fields
    for key, value in self.get_fields().items():
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 1044, in get_fields
    ret[field_name] = field_cls(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/rest_framework/", line 867, in __init__
    super(DateField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'min_value'

self in the last line is DateField(allow_null=True,, 1, 1), required=False)

As I understand it - the validator is a valid model field argument but it errors out with django rest framework. I'm using 3.0.2. Not sure if it's related to this somewhat vague issue Thanks!

@tomchristie tomchristie added this to the 3.0.3 Release milestone Jan 2, 2015
@tomchristie tomchristie added the Bug label Jan 2, 2015
Copy link

tomchristie commented Jan 2, 2015

Thanks for reporting this. We try to coerce MinValueValidator into a min_value keyword argument, but looks like we should also be making sure we only do so for serializer fields that support min_value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants