How to change how foreign keys are view in admin site

7 views
Skip to first unread message

Usman Hassan

unread,
Nov 15, 2019, 12:49:25 PM11/15/19
to Django users
I have a problem with my django app, I created a an that has two models one which is post and the other is comment, and the comment has a foreign key relationship to post. But anytime I view the admin site and I tried to relate a comment to a post I made, it won't show me the title of the post but instead it will show 'post object (1)'. Pls I there any way I can change that???

Paras Jain

unread,
Nov 15, 2019, 2:00:57 PM11/15/19
to django...@googlegroups.com
after that model write like this
def __str__(self):
      return self.title

On Fri, Nov 15, 2019 at 6:18 PM Usman Hassan <usmanh...@gmail.com> wrote:
I have a problem with my django app, I created a an that has two models one which is post and the other is comment, and the comment has a foreign key relationship to post. But anytime I view the admin site and I tried to relate a comment to a post I made, it won't show me the title of the post but instead it will show 'post object (1)'. Pls I there any way I can change that???

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c92d6f0a-b50f-4d7a-adf8-fd0e3b04a801%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages