我正在尝试使用 Django 脆皮形式创建一个 Django 应用程序。
设置.py
CRISPY_TEMPLATE_PACK = 'bootstrap3'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'face', #app name
'crispy_forms',
)
Run Code Online (Sandbox Code Playgroud)
索引.html
{% extends "base.html" %}
{% load crispy_forms_tag %}
{% block title %}
AuthorizedUser
{% endblock title %}
{% block content %}
<h1>Quote of the Day</h1>
<blockquote>{{quote}}</blockquote>
<p>Or, hit reload if you want a new one...</p>
<form method="POST" action="{% url %}" >
{% csrf_token %}
{{ form|crispy}}
<input type="hidden" name="quote" value="{{quote}}" />
<input type="hidden" name="access_token" value="{{access_token}}" /> …Run Code Online (Sandbox Code Playgroud) 我正在创建一个脚本,使用Google-api-python-client为特定的Google Apps用户下载文件.首先,我试图获取用户帐户包含的文件列表.我按照链接https://developers.google.com/drive/v2/reference/files/list中给出的示例进行操作
代码块如下
用户对客户的授权
def authorize_application(request):
#setting flow to get permission and code
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI, ACCESS_TYPE)
authorize_url = flow.step1_get_authorize_url()
code = request.GET.get('code', '')
if code:
#import ipdb
#ipdb.set_trace()
#setting flow step2 to exchage code for access token
credential = flow.step2_exchange(code)
#initialising httplib2 instance and building a DriveAPI service
http = httplib2.Http()
http = credential.authorize(http)
drive_service = build('drive', 'v2', http=http)
# getting user's data
about = drive_service.about().get().execute()
user_info = about.get('user')
email = user_info.get('emailAddress')
request.session['username'] = …Run Code Online (Sandbox Code Playgroud)