Google-api-python-client: django_sample - how do I run it?

Created on 18 Aug 2017  路  3Comments  路  Source: googleapis/google-api-python-client

Hi guys,

I'm having troubles with using the django_sample project.
After I run the server and log in as a superuser, it redirects me to the base URL and throws following error:
`
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.3
Python Version: 2.7.12
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'plus']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware')

Traceback:
File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, callback_args, *callback_kwargs)
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  2. return view_func(request, args, *kwargs)
    File "/var/www/google-api-python-client/samples/django_sample/../django_sample/plus/views.py" in index
  3. credential = storage.get()
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/oauth2client/client.py" in get
  4. return self.locked_get()
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/oauth2client/contrib/django_util/storage.py" in locked_get
  5. if len(entities) > 0:
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  6. self._result_cache = list(self.iterator())
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  7. for row in compiler.results_iter():
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  8. for rows in self.execute_sql(MULTI):
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  9. cursor.execute(sql, params)
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  10. return self.cursor.execute(sql, params)
    File "/var/www/google-api-python-client/virtualenv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  11. return Database.Cursor.execute(self, query, params)

Exception Type: DatabaseError at /
Exception Value: no such column: plus_credentialsmodel.credential
I also filled my access credentials in the client_secrets.json file: {
"web": {
"client_id": "secured",
"client_secret": "secured",
"redirect_uris": [],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
`
How do I fix this?
Thank you

cleanup question

Most helpful comment

The django_sample is out of date as it designed for Django 1.3. I got it to work by upgrading the django project to django 1.11 it wasn't easy. I might create a pull request

All 3 comments

Seems like you're missing the CredentialsModel table in your database.
Try running

python manage.py makemigrations
python manage.py migrate

before running
python manage.py runserver

The django_sample is out of date as it designed for Django 1.3. I got it to work by upgrading the django project to django 1.11 it wasn't easy. I might create a pull request

Closing this, as it is effectively a dupe of #166 (the sample needs to be updated for a more recent Django).

Was this page helpful?
0 / 5 - 0 ratings