0
我有用于从一个API下载数据,然后将其存储到本地数据库中的命令,这是目前我的应用程序的一部分,但我想补充的能力,从manage.py命令运行它。Django的自定义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)