'dan itibaren durdu. Uygulamalarımdan birine Google Calendar API documentation tarafından sağlanan kodu ekleyene kadar gayet iyi çalışan bir Django (1.9.1) projem var.Google Calendar API, Django'yı
Bu kod da ben bağımsız modunda çalıştırın, ama Django projesi içinde kod kullanmaya çalıştığımda "piton manage.py runserver" çalıştırdığınızda bu mesajı alınca benim sanal env'deki çalışıyor:
Ben makemigrations veya göç çalıştırmayı denediğinizde./manage.py runserver
Performing system checks...
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
da bu hata oluşur.
Görünüşe göre hata bana ne yapacağımı söylüyor, ama ben gerçekten anlamadım. Değiştir
from __future__ import print_function
import httplib2
import os
from apiclient import discovery
import oauth2client
from oauth2client import client
from oauth2client import tools
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None
SCOPES = 'https://www.googleapis.com/auth/calendar'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Google Calendar API Python Quickstart'
def get_credentials():
"""Gets valid user credentials from storage.
If nothing has been stored, or if the stored credentials are invalid,
the OAuth2 flow is completed to obtain the new credentials.
Returns:
Credentials, the obtained credential.
"""
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.credentials')
if not os.path.exists(credential_dir):
os.makedirs(credential_dir)
credential_path = os.path.join(credential_dir,
'calendar-python-quickstart.json')
store = oauth2client.file.Storage(credential_path)
credentials = store.get()
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
flow.user_agent = APPLICATION_NAME
if flags:
credentials = tools.run_flow(flow, store, flags)
else: # Needed only for compatibility with Python 2.6
credentials = tools.run(flow, store)
print('Storing credentials to ' + credential_path)
return credentials
def add_event(event):
"""Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
"""
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http)
print("Adding to calendar")
event = service.events().insert(calendarId='<email>', body=event).execute()
print('Event created: %s' % (event.get('htmlLink')))
ile
Tedbiri elden bırakmamak için, burada çalıştırmak çalışıyorum koddur yazılmış? – JRodDynamite
Django uygulamalarından birinin kökünde bulunan bir python dosyasında. Sorduğun şey bu mu, @JasonEstibeiro? –
Bu konum, @JasonEstibeiro geçerli: https://github.com/hannonq/bcc264-email/tree/master/push_email yukarıda belirtilen dosya "utils tarafından çağrılan "calendarhandler.py" dir .py " –