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'):
    field.is_required=False

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.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s