There are 3 models.
class Autor(models.Model): name = models.CharField(max_length=150, unique=True) description = models.CharField(max_length=250) class Book(models.Model): name = models.CharField(max_length=150, unique=True) country = models.CharField(max_length=50) class Genre(models.Model): name = models.CharField(max_length=150) autor = models.ForeignKey('Autor', on_delete=models.CASCADE) book = models.ForeignKey('Book', on_delete=models.CASCADE) There is such a test:
assert response_data[1]['name'] == 'Horor' assert response_data[1]['book'] == 'first' assert response_data[1]['autor'] == 'Vova' assert response_data[1]['description'] == '' In views I do this:
class CategoryView(DetailView): model = Autor template_name = '_' I understood it is necessary somehow through get_context_data (). And how then to turn in the template to the fields from different tables? Or do you need to link the table not by id, but by name?