Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django Can';不要启动新项目_Django_Python 2.7 - Fatal编程技术网

Django Can';不要启动新项目

Django Can';不要启动新项目,django,python-2.7,Django,Python 2.7,我正在做这个教程- 到目前为止,我正在尝试浏览我的应用程序… 但我只得到: Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "C:\NetMagProjekt\n

我正在做这个教程-
到目前为止,我正在尝试浏览我的应用程序…
但我只得到:

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "C:\NetMagProjekt\netmag\blog\views.py" in index
  8.     return render(request, 'blog/index.html', {'posts': posts})
File "C:\Python27\lib\site-packages\django\shortcuts\__init__.py" in render
  44.     return HttpResponse(loader.render_to_string(*args, **kwargs),
File "C:\Python27\lib\site-packages\django\template\loader.py" in render_to_string
  169.         t = get_template(template_name)
File "C:\Python27\lib\site-packages\django\template\loader.py" in get_template
  145.     template, origin = find_template(template_name)
File "C:\Python27\lib\site-packages\django\template\loader.py" in find_template
  134.             source, display_name = loader(name, dirs)
File "C:\Python27\lib\site-packages\django\template\loader.py" in __call__
  42.         return self.load_template(template_name, template_dirs)
File "C:\Python27\lib\site-packages\django\template\loader.py" in load_template
  45.         source, display_name = self.load_template_source(template_name, template_dirs)
File "C:\Python27\lib\site-packages\django\template\loaders\filesystem.py" in load_template_source
  39.                     return (file.read().decode(settings.FILE_CHARSET), filepath)
File "C:\Python27\Lib\encodings\utf_8.py" in decode
  16.     return codecs.utf_8_decode(input, errors, True)

Exception Type: UnicodeDecodeError at /
Exception Value: 'utf8' codec can't decode byte 0xa0 in position 26: invalid start byte
Settings.py:

TEMPLATE_DIRS = (
    "C:/NetMagProjekt/netmag/netmag/Templates",
)
视图:


没有主意。。。有什么想法吗?

您的模板编码不正确。将其另存为UTF-8。

您的模板编码不正确。另存为UTF-8

from django.shortcuts import render, get_object_or_404
from blog.models import Post

def index(request):
    # get the blog posts that are published
    posts = Post.objects.filter(published=True)
    # now return the rendered template
    return render(request, 'blog/index.html', {'posts': posts})