Skip to content
Advertisement

Detail view is not displaying content of models

My detail View in Django, isn’t successfully displaying the content selected from the listviews. The following is my code.

Models.py:

JavaScript

urls.py:

JavaScript

Views.py:

JavaScript

Html list view:

JavaScript

Html detail view:

JavaScript

I hope my query made sense. I don’t receive any error on myside, its just not working as it should.

Advertisement

Answer

The object data is passed as object and post_model, not Post, so:

JavaScript

Note: Models normally have no …Model suffix. Therefore it might be better to rename Post_Model to Post.


Note: It is normally better to make use of the settings.AUTH_USER_MODEL [Django-doc] to refer to the user model, than to use the User model [Django-doc] directly. For more information you can see the referencing the User model section of the documentation.


Note: normally the name of the fields in a Django model are written in snake_case, not PascalCase, so it should be: author instead of Author.

Advertisement