mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:52:21 +01:00
20 lines
502 B
Python
20 lines
502 B
Python
from django.contrib import admin
|
|
|
|
from .models import Song
|
|
|
|
|
|
@admin.register(Song)
|
|
class SongAdmin(admin.ModelAdmin):
|
|
list_display = ('artist', 'title', 'user_name')
|
|
search_fields = ('artist', 'title', 'user__name')
|
|
|
|
@staticmethod
|
|
def user_name(obj):
|
|
try:
|
|
return obj.user.name
|
|
except AttributeError:
|
|
return '<unknown>'
|
|
|
|
@staticmethod
|
|
def get_readonly_fields(request, obj=None):
|
|
return [] if request.user.is_superuser else ['hash'] |