GithubHelp home page GithubHelp logo

Comments (4)

philipn avatar philipn commented on August 27, 2024

I don't know off the top of my head, but I believe I added added in special date time handing here as, at the time, DRF was incapable of correctly parsing ISO 8601 formatted times.

On May 29, 2015, at 4:29 PM, Alex Rothberg [email protected] wrote:

This datetime does not seem to parse correctly: 2010-1-2T23:18:23.861723Z even though DRF handles the format.


Reply to this email directly or view it on GitHub.

from django-rest-framework-filters.

philipn avatar philipn commented on August 27, 2024

@cancan101 You may want to investigate here: https://github.com/philipn/django-rest-framework-filters/blob/master/rest_framework_filters/filters.py#L12

We may simply want to remove these definitions, as it appears DRF fixes this issue in its 3.0 release?

from django-rest-framework-filters.

cancan101 avatar cancan101 commented on August 27, 2024

I think it's actually Django which handles the datetime parsing: https://github.com/django/django/blob/0ed7d155635da9f79d4dd67e4889087d3673c6da/django/utils/dateparse.py#L84-L109

from django-rest-framework-filters.

cancan101 avatar cancan101 commented on August 27, 2024

Something like this (perhaps with a check to see if 'iso-8601' is in api_settings.DATETIME_INPUT_FORMATS):

class DateTimeFormFieldFixed(forms.DateTimeField):
    def to_python(self, value):
        try:
            return super(DateTimeFormFieldFixed, self).to_python(value)
        except ValidationError as ex:
            if ex.code != 'invalid':
                raise
            try:
                result = parse_datetime(value)
            except ValueError:
                raise ValidationError(self.error_messages['invalid'], code='invalid')
            if result is None:
                raise
        return from_current_timezone(result)


class DateTimeFilterFixed(DateTimeFilter):
    field_class = DateTimeFormFieldFixed

from django-rest-framework-filters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.