Skip to content

Instantly share code, notes, and snippets.

View adamalton's full-sized avatar

Adam Alton adamalton

View GitHub Profile
@adamalton
adamalton / views.py
Last active September 21, 2016 09:45
Google multiple sign-in on App Engine
from django.shortcuts import redirect
from google.appengine.api.users import (
create_login_url,
create_logout_url,
get_current_user,
)
def switch_accounts(request):
""" View function for allowing a user to switch Google accounts.
Requires 'destination_url' in the query string for the URL
@adamalton
adamalton / template.html
Last active December 16, 2015 06:09
Example of pagination on Google App Engine which allows going back a page
<h1>Page 1</h1>
<a href="/myview/?page={{previous_page_number}}">Previous page</a>
<a href="/myview/?page={{next_page_number}}">Next page</a>
{% for object in results %}
{{object}} {#whatever you're displaying #}
{% endfor %}
@adamalton
adamalton / template.html
Last active December 16, 2015 06:09
Simple pagination example on Google App Engine
<h1>Page 1</h1>
<a href="/myview/?cursor={{cursor_for_next_page}}">Next page</a>
{% for object in results %}
{{object}} {#whatever you're displaying #}
{% endfor %}