Silent Failure of InlineAdmin Class With a DateTimeField on the Model if Only a "time with timezone" Column in the Database
|Reported by:||vincitveritas||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Ok, this is definitely an edge case, but I ran into this when trying to update a model to add another DateTimeField in one of my projects with an existing database in place. I tried to manually create the db column (postgres), but inadvertently did a "time with timezone" column type instead of "timestamp with timezone". I then went to test the code change on the site's admin. Everything seemed fine, until I actually entered a date and time for the field. The next time I loaded up the admin change page, the inline for that particular inlinemodeladmin just wasn't there. So, I went into the shell and deleted the value from the field and saved. Then, I reloaded the admin change page. Et voila, the inline returned. After much head scratching, I realized what I had done and dropped the incorrectly typed column from the db table and re-created it with the correct type. I was then able to set the value and the inline showed up as expected.
What concerns me is that no error was raised by the mismatch between the DateTimeField declaration in the model definition and the incorrectly-typed db column, only the disappearing inlinemodeladmin. Something just doesn't seem right there.