Created
August 30, 2019 21:32
-
-
Save nshafer/71a249b483914796c1e16c0063278342 to your computer and use it in GitHub Desktop.
Session Admin for debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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