UnicodeDecodeError at / 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte when rendering new template

I'm trying to render a template that extends from my base.html. however I'm getting this error.enter image description here

I tried to change my template directory location (from the app folder to the project root). I also made my Templates directory point to the right place in my settings file. The problem occurred after i made this change. I tried to put the templates folder back in the same location but it didn't work afterwards.

Im quite new to Django. would greatly appreciate if you can show me what i'm doing wrong.

My template file

{% extends 'base.html' %}
{% block breadcrumb %}
    <li class="breadcrumb-item active" >Blog Categories</li>
{% endblock %}

{% block content %}

<table class = “table”>
<thead class=“thead-inverse” >
<tr>
<th>Category</th>
<th>Description</th>
<th>Number of Blogs</th>
<th>Last Post</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
{% for category in categories %}
<tr>
<td>
<a href=“{% url ‘category’ category.pk %}”>{{category.name}}</a>
</td>
<td>
{{category.description}}
</td>
<td class=“align-middle” >0</td>
<td class=“align-middle” >0</td>
<td><a>Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

Traceback:

    Traceback (most recent call last):
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py”, line 34, in inner
response = get_response(request)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py”, line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py”, line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “C:\Users\arfat\pycharmprojects\FormProject\myformapp\blog\views.py”, line 10, in home
return render(request, ‘home.html’, {‘categories’: categories})
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\shortcuts.py”, line 36, in render
content = loader.render_to_string(template_name, context, request, using=using)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader.py”, line 62, in render_to_string
return template.render(context, request)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py”, line 61, in render
return self.template.render(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py”, line 171, in render
return self._render(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py”, line 163, in _render
return self.nodelist.render(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py”, line 937, in render
bit = node.render_annotated(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py”, line 904, in render_annotated
return self.render(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py”, line 127, in render
compiled_parent = self.get_parent(context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py”, line 124, in get_parent
return self.find_template(parent, context)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py”, line 104, in find_template
template_name, skip=history,
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\engine.py”, line 126, in find_template
template = loader.get_template(name, skip=skip)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loaders\base.py”, line 24, in get_template
contents = self.get_contents(origin)
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loaders\filesystem.py”, line 24, in get_contents
return fp.read()
File “C:\Users\arfat\AppData\Local\Programs\Python\Python37-32\lib\codecs.py”, line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)


#django #python

5 Likes6.35 GEEK