I think the admin user record is inserted twice because you run the createAdmin() function once in runserver.py, and then, for some reason it will be run again when you start your app with app.run(debug=True). I do not understand why gets re-run, but I have seen the same issue. If you do not start the app, then the createAdmin() will be run only once (I would expect).