1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #31181 -- Added links to related models for admin's readonly fields.

This commit is contained in:
Julien Rebetez
2020-01-18 19:03:03 +01:00
committed by Mariusz Felisiak
parent 855fc06236
commit b790883065
5 changed files with 87 additions and 11 deletions

View File

@@ -37,8 +37,8 @@ from .models import (
Person, Persona, Picture, Pizza, Plot, PlotDetails, PlotProxy,
PluggableSearchPerson, Podcast, Post, PrePopulatedPost,
PrePopulatedPostLargeSlug, PrePopulatedSubPost, Promo, Question,
ReadablePizza, ReadOnlyPizza, Recipe, Recommendation, Recommender,
ReferencedByGenRel, ReferencedByInline, ReferencedByParent,
ReadablePizza, ReadOnlyPizza, ReadOnlyRelatedField, Recipe, Recommendation,
Recommender, ReferencedByGenRel, ReferencedByInline, ReferencedByParent,
RelatedPrepopulated, RelatedWithUUIDPKModel, Report, Reservation,
Restaurant, RowLevelChangePermissionModel, Section, ShortMessage, Simple,
Sketch, Song, State, Story, StumpJoke, Subscriber, SuperVillain, Telegram,
@@ -539,6 +539,10 @@ class PizzaAdmin(admin.ModelAdmin):
readonly_fields = ('toppings',)
class ReadOnlyRelatedFieldAdmin(admin.ModelAdmin):
readonly_fields = ('chapter', 'language', 'user')
class StudentAdmin(admin.ModelAdmin):
search_fields = ('name',)
@@ -1061,6 +1065,7 @@ site.register(GenRelReference)
site.register(ParentWithUUIDPK)
site.register(RelatedPrepopulated, search_fields=['name'])
site.register(RelatedWithUUIDPKModel)
site.register(ReadOnlyRelatedField, ReadOnlyRelatedFieldAdmin)
# We intentionally register Promo and ChapterXtra1 but not Chapter nor ChapterXtra2.
# That way we cover all four cases: