gpt4 book ai didi

python - manage.py:错误:无法识别的参数:runserver 8000,Google Analytics API Django

转载 作者:行者123 更新时间:2023-12-03 17:11:21 25 4
gpt4 key购买 nike

这是我的Models.py

import argparse
import os
from django.db import models
from django.db import models
from django.contrib.auth.models import User
from oauth2client import tools
from oauth2client.client import flow_from_clientsecrets, Storage
CLIENT_SECRETS = os.path.join(
os.path.dirname(__file__), 'client_secrets.json')
TOKEN_FILE_NAME = 'credentials.dat'
FLOW = flow_from_clientsecrets(
CLIENT_SECRETS,
scope='https://www.googleapis.com/auth/analytics.readonly',
message='%s is missing' % CLIENT_SECRETS
)
def prepare_credentials():
parser = argparse.ArgumentParser(parents=[tools.argparser])
flags = parser.parse_args()
# Retrieve existing credendials
storage = Storage(TOKEN_FILE_NAME)
credentials = storage.get()
# If no credentials exist, we create new ones
if credentials is None or credentials.invalid:
credentials = tools.run_flow(FLOW, storage, flags)
return credentials



class FlowModel(models.Model):
id = models.ForeignKey(User, primary_key=True)
flow = FLOW


class CredentialsModel(models.Model):
id = models.ForeignKey(User, primary_key=True)
credential = prepare_credentials()


当我运行python manage.py runserver
它给我下面的错误

      usage: manage.py [-h] [--auth_host_name AUTH_HOST_NAME]
[--noauth_local_webserver]
[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
manage.py: error: unrecognized arguments: runserver 8000


我尝试搜索解决方案,但此错误仍然存​​在。
请用尽时间解决我的问题。

最佳答案

尝试更换:

parser = argparse.ArgumentParser(parents=[tools.argparser])




parser = tools.argparser.parse_args([])

关于python - manage.py:错误:无法识别的参数:runserver 8000,Google Analytics API Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46551454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com