Skip to content

Instantly share code, notes, and snippets.

@nshafer
Created August 30, 2019 21:32
Show Gist options
  • Save nshafer/71a249b483914796c1e16c0063278342 to your computer and use it in GitHub Desktop.
Save nshafer/71a249b483914796c1e16c0063278342 to your computer and use it in GitHub Desktop.
Session Admin for debugging
from django.contrib.sessions.models import Session
class SessionAdmin(admin.ModelAdmin):
list_display = ('session_key', 'decoded_session_data', 'expire_date')
readonly_fields = ('decoded_session_data',)
exclude = ('session_data',)
ordering = ('expire_date',)
search_fields = ('session_key',)
def decoded_session_data(self, obj):
return mark_safe(pprint.pformat(obj.get_decoded()).replace('\n', '<br>\n'))
if settings.DEBUG:
admin.site.register(Session, SessionAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment