def create_or_reset_admin(context, settings_path=None):
'''
Creates an admin user or resets the password for an existing one
'''
# Find the path to the settings and setup the django environment
setup_django_environment(settings_path)
# can't be imported in global scope as it already requires
# the settings module during import
from wger.manager.models import User
try:
admin = User.objects.get(username="admin")
print("*** Password for user admin was reset to 'admin'")
except User.DoesNotExist:
print("*** Created default admin user")
# os.chdir(os.path.dirname(inspect.stack()[0][1]))
# current_dir = os.path.join(os.getcwd(), 'wger')
current_dir = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(current_dir, 'wger', 'core', 'fixtures/')
call_command("loaddata", path + "users.json")
评论列表
文章目录