Skip to content

Instantly share code, notes, and snippets.

import requests
import datetime
import json
from django.core.cache import cache
from django.conf import settings
GFYCAT_GET_URL = 'https://api.gfycat.com/v1/gfycats/{}'
GFYCAT_TOKEN_URL = 'https://api.gfycat.com/v1/oauth/token/'
GFYCAT_TOKEN_CACHE_KEY = 'gfycat_token'
from django.contrib.admin.views.main import ChangeList, ORDER_VAR
class NoPkChangeList(ChangeList):
def get_ordering(self, request, queryset):
"""
Returns the list of ordering fields for the change list.
First we check the get_ordering() method in model admin, then we check
the object's default ordering. Then, any manually-specified ordering
from the query string overrides anything. Finally, WE REMOVE the primary
key ordering field.
"""
Gist code by vstoykov, you can check his original gist at:
https://gist.github.com/vstoykov/1390853/5d2e8fac3ca2b2ada8c7de2fb70c021e50927375
Changes:
Ignoring static file requests and a certain useless admin request from triggering the logger.
Updated statements to make it Python 3 friendly.
"""
@angysmark
angysmark / appsync_client.py
Last active July 23, 2022 17:29
Make a GraphQL Appsync client in Python
import json
import os
from boto3 import Session as AWSSession
from requests_aws4auth import AWS4Auth
from gql import gql
from gql.client import Client
from gql.transport.requests import RequestsHTTPTransport