Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My investigations into this are in the question as a set of edits, but the long and short of this is that changes to the to_python method between 1.4 and 1.5 mean that anything that is neither a valid datetime.date nor datetime.datetime must be a string in order to pass through. </p> <p>It looks (without too much further digging) as if the <code>django.utils.encoding.smart_str</code> method was removed in 1.5, and although it's been replaced by <code>smart_text</code>, this never made it into the <code>to_python</code> method.</p> <p>I have raised a ticket in the django Trac instance, <a href="https://code.djangoproject.com/ticket/21523" rel="nofollow">https://code.djangoproject.com/ticket/21523</a></p> <p>I have also created a patch for this issue - but obviously this may never make it in (and the patch is for 1.5.x, which is already out-of-date, so I really wouldn't count on this making it in).</p> <p><strong>[EDIT 1: a solution!]</strong></p> <p>There is a solution ;-) - I have done a write up here - <a href="http://tech.yunojuno.com/mocking-dates-with-django" rel="nofollow">http://tech.yunojuno.com/mocking-dates-with-django</a> - the key is overriding the FakeDate <strong>instancecheck</strong> method, so that when comparing a real datetime.date to a FakeDate you get True. I have put together a gist with some sample FakeDate classes and associated tests for reference - <a href="https://gist.github.com/hugorodgerbrown/7750432" rel="nofollow">https://gist.github.com/hugorodgerbrown/7750432</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload