Error: the following arguments are required: new (How to Build an E-commerce Website with Django and Python)

Error: the following arguments are required: new (How to Build an E-commerce Website with Django and Python)

我正在尝试开始本教程...我不得不 pip 安装一些包并稍微调整 requirements.txt。现在,我正在尝试重命名项目,但出现错误:

manage.py rename: error: the following arguments are required: new

https://www.youtube.com/watch?v=YZvRrldjf1Y&t=1485s&ab_channel=freeCodeCamp.org

import os
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    help = 'Renames a Django project'

    def add_arguments(self, parser):
        parser.add_argument('current', type=str, nargs='+',
                            help='The current Django project folder name')
        parser.add_argument('new', type=str, nargs='+',
                            help='The new Django project name')

    def handle(self, *args, **kwargs):
        current_project_name = kwargs['current'][0]
        new_project_name = kwargs['new'][0]

        # logic for renaming the files

        files_to_rename = [f'{current_project_name}/settings/base.py',
                           f'{current_project_name}/wsgi.py', 'manage.py']

        for f in files_to_rename:
            with open(f, 'r') as file:
                filedata = file.read()

            filedata = filedata.replace(current_project_name, new_project_name)

            with open(f, 'w') as file:
                file.write(filedata)

        os.rename(current_project_name, new_project_name)

        self.stdout.write(self.style.SUCCESS(
            'Project has been renamed to %s' % new_project_name))

您可能使用比视频更新的 Django 版本。在这种情况下,您需要键入(以使用视频中的值):

python manage.py rename demo djecommerce

重命名命令现在需要旧文件夹名称和新名称。