Upgrading Django – AddManipulators and backwards incompatible changes

I was doing some upgrading of a Django site, getting rid of some of the pieces that are listed in the upcoming backwards-incompatible changes list. Learned some interesting tidbits…

For one, the AddManipulators (being deprecated as things move to newforms instead of the Manipulators setup) don’t play nicely with the removal of LazyDate and auto_add_now functionality from the older models setup. My terribly hack workaround, since I don’t use too many of the AddManipulators, is to tweak them when I run into it.

In particular I’m storing “creation_time” for some objects (which had been set to auto_add_now), and the AddManipulator decided that it was required, regardless of “null=True” or other goodies. I was overriding the save() method in the model – so I’m getting the data… but the Manipulator was being a pain. My tweak for the Manipulator went something like this:

book_manipulator = Book.AddManipulator()
for field in topic_manipulator.fields:
  if field.field_name.startswith('creation_time'):

Which appears to have resolved the whole “creation_time_time” and “creation_time_date” fields being required and stuffing up my otherwise nicely functioning forms. Hopefully nobody else will run into this and need this hack (at least until I get rid of the AddManipulators in favor of the newforms setup) – but just in case, I thought I’d make it nicely available for Google.

Published by heckj

Developer, author, and life-long student. Writes online at https://rhonabwy.com/.

%d bloggers like this: