我有一个命令用于从 API 下载数据,然后将其存储到本地数据库中,它目前是我的应用程序的一部分,但我想添加从 manage.py 命令运行它的能力。
目前我只是想在我的应用程序中使用正确的参数调用它,但我得到一个与模型相关的错误
错误:
File "C:\xxx\Development\working folder\appdata\globaltags\boughtintags.py", line 2, in <module>
import appdata.boughtin.models as models
AttributeError: 'module' object has no attribute 'models'
我正在使用的当前代码:
class Command(BaseCommand):
args = '<queryset_uuid queryset_item_uuid>'
help = 'Downloads arbitrary items using a download script'
def handle(self, *args, **options):
for queryset_uuid, queryset_item_uuid in args:
if download_queryset(queryset_uuid=queryset_uuid, queryset_item_uuid=queryset_item_uuid):
self.stdout.write('Successfully downloaded "%s"\n' % queryset_item_uuid)
else:
raise CommandError('Unable to download "%s"\n' % queryset_item_uuid)