The problem is not in the template. Judging by the screenshot, your posts variable is a lazy QuerySet, which climbs to the database for posts only at the first access to it, and it turned out that for post in posts in the template turned out to be this very first call. As a result, the template accesses the database, and this appeal falls because of the missing column in the table, which was registered in the model.
Models only describe how tables and columns and their associated data should be interpreted, which are stored in the database, but do not manage these tables and columns in the database in any way. If a field has been added or deleted in the model, the corresponding column will not be automatically changed in the database itself. In general, it is impossible to do this automatically for various technical and logical reasons, but it is semi-automatically possible - for this there are migrations.
The brief point is this: when changing a model, we run makemigrations , junga looks at changes in the model and tries to guess what changes need to be made in the database (most often it guesses correctly, but not always); The migration is saved to a file, after which we modify the database itself according to the instructions in this migration by running the migrate command.
Details about all this in the official documentation: https://djbook.ru/rel1.9/topics/migrations.html (translation)