Trying to setup a webpage to list the tags for startups (following along in Django unleashed). The book uses Django 1.8, and Im using 3.0. There are spots where ive seen deprecated functions in the book and was able to find what the updated replacement was, but i cant figure out why django is giving me this error when loading the homepage. Still kinda new at Python and Django. I do have tags created, when executing Tag.objects.all()
and one startup has been saved to the database which has its related tag.
Views.py
from django.shortcuts import render
from django.http.response import HttpResponse
from .models import Tag
from django.template import Template, Context, loader
def homepage(request):
tag_list = Tag.objects.all()
template = loader.get_template('organizer/tag_list.html')
context = Context({'tag_list':tag_list})
output = template.render(context)
return HttpResponse(output)
Tag_list.html
{% extends parent_template|default:"organizer/base_organizer.html" %} #An alternative reference to "base.html"
{% block title %}
{{ block.super }} - Tag List
{% endblock %}
{% block content%}
<h2>Tag List</h2>
<ul>
{% for tag in tag_list %}
<li>
<a href="">
{{ tag.name|title }}</a>
</li>
{% empty %}
<p><em>There are currently no Tags available.</em></p>
{% endfor %}
</ul>
{% endblock %}
TypeError at /
context must be a dict rather than Context.
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 3.0
Exception Type: TypeError
Exception Value:
context must be a dict rather than Context.
Exception Location: C:\Users\Antho\Desktop\suorganizer\su_env\lib\site-packages\django\template\context.py in make_context, line 270
Python Executable: C:\Users\Antho\Desktop\suorganizer\su_env\Scripts\python.exe
Python Version: 3.7.5
Python Path: