Django view UnicodeDecodeError hatası

#1

Merhabalar;

Hata:

Internal Server Error: /
Traceback (most recent call last):
  File "/home/erdem/.local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/erdem/Django Projects/rosmanoglu/home/views.py", line 4, in index
    return render(req, "home/index.html")
  File "/home/erdem/.local/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/backends/django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/engine.py", line 144, in get_template
    template, origin = self.find_template(template_name)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/engine.py", line 126, in find_template
    template = loader.get_template(name, skip=skip)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/loaders/base.py", line 24, in get_template
    contents = self.get_contents(origin)
  File "/home/erdem/.local/lib/python3.6/site-packages/django/template/loaders/filesystem.py", line 24, in get_contents
    return fp.read()
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 4210: invalid start byte

Hatanın nedeni:

home/views.py

from django.shortcuts import render

def index(req):
    return render(req, "home/index.html")
0 Likes

#2

Sorunu çözdüm. Sorun, ASCII kullanan bir template kullanmammış. (Template’i internetten temin etmiştim) Bir kurtulamadık şu ASCII belasından…

0 Likes