<commit_before>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from .models import APNSDevice, GCMDevice, get_expired_tokens


class DeviceAdmin(admin.ModelAdmin):
	list_display = ("__unicode__", "device_id", "user", "active", "date_created")
	search_fields = ("name", "device_id", "user__username")
	list_filter = ("active", )
	actions = ("send_message", "send_bulk_message", "prune_devices", "enable", "disable")

	def send_message(self, request, queryset):
		ret = []<commit_msg>Get username field dynamically in the admin<commit_after>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from .models import APNSDevice, GCMDevice, get_expired_tokens


def _user__username():
	from django.contrib.auth import get_user_model
	return "user__%s" % (get_user_model().USERNAME_FIELD)


class DeviceAdmin(admin.ModelAdmin):
	list_display = ("__unicode__", "device_id", "user", "active", "date_created")
	search_fields = ("name", "device_id", _user__username())
	list_filter = ("active", )
	actions = ("send_message", "send_bulk_message", "prune_devices", "enable", "disable")

	def send_message(self, request, queryset):
		ret = []
{'fraction_non_alphanumeric': 0.13112033195020747, 'fraction_numerical': 0.0, 'mean_word_length': 7.148648648648648, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7362275', 'n_tokens_mistral': 391, 'n_tokens_neox': 382, 'n_words': 95}