summaryrefslogtreecommitdiff
path: root/tests/admin_views/admin.py
diff options
context:
space:
mode:
authorJulien Rebetez <julien@fhtagn.net>2020-01-18 19:03:03 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-10-08 19:53:49 +0200
commitb79088306513d5ed76d31ac40ab3c15f858946ea (patch)
treee384bad39afe191ff65fba937b0f4ff7a3a8c8cb /tests/admin_views/admin.py
parent855fc06236630464055b4f9ea422c68a07c6d02a (diff)
Fixed #31181 -- Added links to related models for admin's readonly fields.
Diffstat (limited to 'tests/admin_views/admin.py')
-rw-r--r--tests/admin_views/admin.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index 44623e483f..4a72e3070f 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -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: