Django: Getting Started Transcripts
Chapter: Posting Data
Lecture: Writing an Admin class for the 'ReviewModel'

Login or purchase this course to watch this video and the rest of the course contents.
0:00 You've seen most of this before. I've registered an admin model for the review class and on line 11,
0:06 I'm configuring the columns for the listing page it will show the reviews IDs. Whatever show user and show book return.
0:14 I'll get to that a second, then the rating field, and finally whatever show summary returns So let's discuss those whatevers.
0:24 Show user is a link to this reviews user admin page. Using reverse to look up the admin user models change list
0:31 and adding the query parameter that filters the page to just that user. Show book is the same idea, but for the reviews book attribute.
0:42 The last one shows summary is a bit different. This is going to show a little bit of what the user wrote in their review.
0:48 This is a single line of code because Django has an undocumented feature that knows how to truncate text based on word boundaries.
0:56 If it's undocumented you might say how'd you know it was there? Well there's a template filter that does this that is documented.
1:04 So I looked in the source code of that template filter and found this handy utility.
1:09 In the previous chapter, I created the people app to manage the data associated with each user.
1:14 In doing so I created both an in line admin for the reader object and overloaded the user admin. As our users will have reviews.
1:23 It might be handy to see the review objects associated with each user. To do that, I'm going to add some code to people admin.py.


Talk Python's Mastodon Michael Kennedy's Mastodon