Fixed possible issue not catching duplicate key errors
Fix circular import issue with django auth (#531) (#545)