{"action":"created","issue":{"url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/864","labels_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/864/labels{/name}","comments_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/864/comments","events_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/864/events","html_url":"https://github.com/MongoEngine/mongoengine/pull/864","id":56719718,"number":864,"title":"ComplexDateTimeField should fallback to None if null=True","user":{"login":"jimmyshen","id":548125,"avatar_url":"https://avatars.githubusercontent.com/u/548125?v=3","gravatar_id":"","url":"https://api.github.com/users/jimmyshen","html_url":"https://github.com/jimmyshen","followers_url":"https://api.github.com/users/jimmyshen/followers","following_url":"https://api.github.com/users/jimmyshen/following{/other_user}","gists_url":"https://api.github.com/users/jimmyshen/gists{/gist_id}","starred_url":"https://api.github.com/users/jimmyshen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimmyshen/subscriptions","organizations_url":"https://api.github.com/users/jimmyshen/orgs","repos_url":"https://api.github.com/users/jimmyshen/repos","events_url":"https://api.github.com/users/jimmyshen/events{/privacy}","received_events_url":"https://api.github.com/users/jimmyshen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-02-05T19:49:49Z","updated_at":"2015-02-11T07:17:14Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/MongoEngine/mongoengine/pulls/864","html_url":"https://github.com/MongoEngine/mongoengine/pull/864","diff_url":"https://github.com/MongoEngine/mongoengine/pull/864.diff","patch_url":"https://github.com/MongoEngine/mongoengine/pull/864.patch"},"body":"Hi,\r\n\r\nI was playing with the new 'null' behavior, which I would like to use in a project I'm working on. While messing with it on master, I noticed some inconsistency in the behavior with regard to DateTimeField and ComplexDateTimeField.\r\n\r\nHere's a demonstration:\r\n\r\n```python\r\ndef test_null_datetime_fields():\r\n    class TestDoc(Document):\r\n        dt_field = DateTimeField(null=True)\r\n        cdt_field = ComplexDateTimeField(null=True)\r\n\r\n    doc = TestDoc()\r\n    doc.save()\r\n\r\n    assert doc.dt_field is None\r\n    assert doc.cdt_field is None\r\n```\r\n\r\nThe cause seems to be related to some logic specific to ComplexDateTimeField that falls back to datetime.now on retrieval from db. I'm not sure what the motivation was for the different behavior between DateTimeField and ComplexDateTimeField -- it was introduced a long time ago and there's even a test to ensure it doesn't regress:\r\n\r\nhttps://github.com/MongoEngine/mongoengine/commit/0187a0e1\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/comments/73841979","html_url":"https://github.com/MongoEngine/mongoengine/pull/864#issuecomment-73841979","issue_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/864","id":73841979,"user":{"login":"DavidBord","id":3276118,"avatar_url":"https://avatars.githubusercontent.com/u/3276118?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidBord","html_url":"https://github.com/DavidBord","followers_url":"https://api.github.com/users/DavidBord/followers","following_url":"https://api.github.com/users/DavidBord/following{/other_user}","gists_url":"https://api.github.com/users/DavidBord/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidBord/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidBord/subscriptions","organizations_url":"https://api.github.com/users/DavidBord/orgs","repos_url":"https://api.github.com/users/DavidBord/repos","events_url":"https://api.github.com/users/DavidBord/events{/privacy}","received_events_url":"https://api.github.com/users/DavidBord/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T07:17:14Z","updated_at":"2015-02-11T07:17:14Z","body":"It will be nicer if you would have added the extra fields to the existing class in the test instead of duplicating some of them to another class\r\nIn addition, please squash your commits "}}