Skip to content

Instantly share code, notes, and snippets.

@elin-moco
Last active December 25, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elin-moco/7053450 to your computer and use it in GitHub Desktop.
Save elin-moco/7053450 to your computer and use it in GitHub Desktop.
Render google form in django views.py
import urllib2
from BeautifulSoup import BeautifulSoup
from django.shortcuts import render
def google_form(request, template='reg/gform.html', formkey=None):
gform = ''
if formkey:
soup = BeautifulSoup(urllib2.urlopen('https://docs.google.com/spreadsheet/viewform?formkey=%s' % formkey).read())
formResult = soup('div', {'class': 'ss-form-container'})
for div in formResult:
gform += div.prettify('utf-8').decode('utf-8')
context = {
'gform': gform,
}
return render(request, template, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment