Django — Detect what fields have been changed / modified on save.

How to detect which fields have been changed upon saving a model.

I just needed a quick way to detect which fields have been changed as a convenience for a team.

This is what I came up with.

Is it too expensive to do comparisons like this?

Please let me know if you have any suggestions.


    def __init__(self, *args, **kwargs):
        super(Order, self).__init__(*args, **kwargs)
        self._initial_data = self.__dict__.copy()

    def detect_changed(self, user='System'):
        changed = [k for k, v in self._initial_data.iteritems() \
                        if v != self.__dict__[k] and k not in ('log','activity','_state',)]
        if changed:
            self._activity("%s changed %s" % (user.first_name, str(changed).replace('[','').replace(']','') ) )

Mac OSX — Terminal Page Up / Page Down Keybindings

How to setup your mac terminal page up and page down shortcuts.

Default for page up/ page down in terminal is to scroll the actual terminal, not send a page up / page down command TO the program in the terminal .

In short, open terminal settings > go to key bindings>

set page up to 33[5~
set page down to 33[6~

Note that 33 is the ESC key. Typing in \ on its own will result in an escape slash (or smth): \\

So in this case, type in ESC, [, 6, and ~.

Let me know if it helped!

Dell M1210 Hackintosh Intel GMA 950 (not Nvidia)

This was fairly painless procedure: 1 shot did the trick.

LOTS Of googlefu was involved.

  1. Installed ideneb 10.5.6
  2. Screen went black after restart, so followed instructions somewhere to log in to the single user mode (f8 -s on darwin startup), mount the drive mount -uw /, and delete the AppelIntelGMA* files.
  3. Reboot, and we have a crappy looking osx launched.
  4. Now, I enabled root account, and downloaded the intel GMA950 kexts from http://www.insanelymac.com/forum/index.php?showtopic=156261
  5. Reboot, and we have full res.
  6. Sound is not around, and neither is my wireless card (looks like I need to get a different one) but this accomplishes my goal of trying OSX to see if I would like it here for web development.