Loading

django自定义命令【示例】

image-20240906200145173
from django.core.management.base import BaseCommand
from ... import models


class Command(BaseCommand):
    def handle(self, *args, **options):
        username = input("用户名:")
        password = input("密码:")
        models.User.objects.create(username=username, password=password, is_super=True)
        print("创建成功")
posted @ 2024-09-06 20:03  一只大学生  阅读(3)  评论(0编辑  收藏  举报