Ascii而不是utf-8

时间:2016-04-04 07:23:44

标签: ascii

我正在django做一个项目,我不明白为什么一切都是用ASCII设置的。

SyntaxError: Non-ASCII character '\xc3' in file
/Users/Harold/Documents/workspace/Project/Project/views.py on line 28, but no
encoding declared; see http://python.org/dev/peps/pep-0263/ for details

错误来自我的views.py(我在那里有一个带有“é”的字符串)和urls.py,但在我写的那两个中   # - - 编码:utf-8 - - 上面

# -*- coding: utf-8 -*-

from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from datetime import *
from Project.models import Note,Vin,Userss,Appelation,Met

def main(request):
    if len(request.GET)==0:
        return render_to_response ('main')


def liste(request):
    vins=Vin.objects.all()
    return render_to_response ('liste',{'liste':vins})

def search(request):
    if len(request.GET)==0:
        return render_to_response('search')
    else:
        vins=request.GET['vin']
        if len(Vin.objects.filter(nom_vin__contains=vins))==0:
            error='Vin(s) non trouvé(s)'                        **# Error in this line**
            return render_to_response('search',{'error':error})
        else:
            liste_vins=Vin.objects.filter(nom_vin__contains=vins)
            return 

0 个答案:

没有答案