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 urllib import urlencode | |
from django.contrib.admin.views.main import ChangeList | |
from django.urls import reverse | |
def change_admin_url(model, **kwargs): | |
class CustomModelChangeList(ChangeList): | |
def url_for_result(self, obj): | |
return model_change_url_only(obj, model._meta, **kwargs) |
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
class ListDisplayClickthroughMixin(object): | |
list_display_fk_clickthrough = [] | |
list_display_m2m_clickthrough = [] | |
def __init__(self, *args, **kwargs): | |
super(ListDisplayClickthroughMixin, self).__init__(*args, **kwargs) | |
for field in self.list_display_fk_clickthrough or []: | |
self.bind_field(field, fk_link_fnc) | |
for field in self.list_display_m2m_clickthrough or []: |
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
//Adapter for RecyclerView, that displays contents of kotlin data class using reflection (or in theory just public properties of a class). | |
import kotlin.reflect.KClass | |
import kotlin.reflect.KProperty1 | |
import kotlin.reflect.KVisibility | |
import kotlin.reflect.full.memberProperties | |
val <T : Any> KClass<T>.publicProperties: Collection<KProperty1<T, *>> | |
get() = memberProperties.filter { it.visibility == KVisibility.PUBLIC } |