[Answered ]-Get category name by id using id from other table. Django

2👍

You’re doing it wrong. You should use a ForeignKey.

class Article(models.Model):
    category = models.ForeignKey('Category')
    ...

Then, when you have an Article object, you can access the attributes of a Category this way :

article.category.name
👤Zashas

Leave a comment