Git Product home page Git Product logo

Comments (4)

lorinkoz avatar lorinkoz commented on June 20, 2024

Empty string should not be valid.

For empty dates None should be used. Is the partial date field null=True?

from django_partial_date.

Josh-Woodcock avatar Josh-Woodcock commented on June 20, 2024

Tried again but still get an error, reproduced below with identifiying information taken out. It appears the error lies in the pareDate function when it receives a blank field.

  ValidationError at /admin/pages/23/edit/
  ["'' is not a valid date string (YYYY, YYYY-MM, YYYY-MM-DD)"]
  Request Method: GET
  Request URL:    http://localhost:8000/admin/pages/23/edit/?next=/admin/dialectics/journal/
  Django Version: 3.1.7
  Exception Type: ValidationError
  Exception Value:    
  ["'' is not a valid date string (YYYY, YYYY-MM, YYYY-MM-DD)"]
  Exception Location: /wagtail-env/lib/python3.8/site-packages/partial_date/fields.py, line 105, in parseDate
  Python Executable:  /wagtail-env/bin/python
  Python Version: 3.8.10

The field is written as ->

  active_end = PartialDateField(
          blank=True,
          null=True,
      )

If it makes any difference we are using Wagtail not pure Django.

from django_partial_date.

lorinkoz avatar lorinkoz commented on June 20, 2024

Please make sure that your forms or any other interface to the useris properly converting the "empty user input" to None instead of "".

from django_partial_date.

xjlin0 avatar xjlin0 commented on June 20, 2024

I encounter the same thing and this is default Django admin page, I have to add blank=True to make the admin page saving work, and convert empty string to None in model's save() method. It maybe more convenient if django_partial_date can ignore the empty string.

https://stackoverflow.com/a/6993885/4257237

from django_partial_date.

Related Issues (5)

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.