tasks.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:wger-lycan-clan 作者: andela 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号