Answer the question
In order to leave comments, you need to log in
How to make multiple templates in one model in django?
Please tell me how to get several templates in the DetailView model depending on the field of the model.
For example, there is a News model with the Article field. How to output a template depending on the article?
And if the template with the given article is not found, get the standard one.
Model example:
class News(models.Model):
created = models.DateTimeField(auto_now_add=True)
article = models.CharField(blank=False,
null=False,
default="",
max_length=50,
verbose_name="Артикул",
db_index=True,
unique=True)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question