Re-work Django code; cleanup.
Re-work Django code; cleanup.