[Answer]-Django redirection issues. Objects not loaded correctly

1👍

✅

Set the context_object_name in your urls to the name you want your object to have in your template.

eg:

    url(r'^(?P<pk>\d+)$',DetailView.as_view(model = blog,template_name="post.html", context_object_name="post")),

Django uses a default context object with the name object (for DetailView) or object_list (for ListView) unless otherwise specified.

Leave a comment