alerion
Файл шаблона не в UTF-8.
Как решить данный вопрос?
А тем более что возник не из-за ничего
P.S. в django я новичок.
В связи с чем появляется подобного рода ошибка?
На что следует обратить внимание, что бы это исправить?
---urls.py---
# -- coding: utf-8 --
from django.conf.urls import patterns, include, url
from mysite.views import my_cabinet, add_new_student, search_form
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# (r'^$', homepage),
(r'^my_cabinet/$', my_cabinet),
(r'^add_new_student/$', add_new_student),
(r'^search_form/$', search_form),
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls))
)
---views.py---
# -- cooding: utf-8 --
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.db import models
from models import Pedagog
import sqlite3
def my_cabinet(request):
# poprobovatt zamenitt niznii zapros na data_b_Students = Pedagog.objects.all pustie kruglie skobki
if 'group_name' in request.GET:
conn = sqlite3.connect('example')
c = conn.cursor()
# message = 'work %r' %request.GET["group_name"]
p = Pedagog(group_index = request.GET["group_name"], fio = request.GET["faln"], stud_no = request.GET["no_isic"], date_birth = request.GET["date_birthday"], course = request.GET["select_course"], comment = request.GET["comment"])
p.save()
# conn.commit()
c.close()
# if 'id' in request.GET:
# conn = sqlite3.connect('example')
# c = conn.cursor()
# p = Pedagog(id = request.GET["id_get"])
# p.delete()
# conn.commit()
# c.close()
conn = sqlite3.connect('example')
c = conn.cursor()
data_b_Students = c.execute("SELECT * FROM mysite_pedagog ORDER by group_index")
conn.commit()
# c.close()
# sdelatt tak, stob mozno bulo zahoditt na stranicu, kogda eche ne bulo metoda get
return render_to_response('my_cabinet.html', locals())
def add_new_student(request):
return render_to_response('add_new_student.html')
def search_form(request):
return render_to_response('search_form.html')
---models.py---
# -- coding: utf-8 --
from django.db import models
class Pedagog(models.Model):
group_index = models.CharField(max_length=15)
fio = models.CharField(max_length=45)
stud_no = models.CharField(max_length=8)
date_birth = models.CharField(max_length=10)
course = models.CharField(max_length=1)
comment = models.TextField(max_length=140)
def __unicode__(self):
return self.fio
class Meta:
ordering = ["group_index"]
---my_cabinet.html---
Pedagog - (pedagog_login_FIO) - saved page
Pedagog
Add
LogOut
Group_index
FIO
Stud_No.
Date_birth
Course
Comment
{% include 'attribute_student.html' %}
THIS is {{ message }}
---attribute_student.html---
{% for element_row in data_b_Students %}
{{ element_row.1 }}
{{ element_row.2 }}
{{ element_row.3 }}
{{ element_row.4 }}
{{ element_row.5 }}
{{ element_row.6 }}
{{ element_row.2 }}
{{ element_row.2 }}
-->
{% endfor %}
---add_new_student.html---
Add new student page
Pedagog
Add
LogOut
Group name
(10 symbols)
First and Last names
(40 symbols)
No. ISIC
(19 symbols)
Date Birthday
(10 symbols)
Select course
1
2
3
4
5
Comment
(300 symbols)
Save changes
Cancel
---Traceback---
C:\Python_folder\mysite>python manage.py runserver 0.0.0.0:8000
Validating models...
0 errors found
Django version 1.4, using settings 'mysite.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.
[08/Jun/2012 03:40:29] "GET /my_cabinet/ HTTP/1.1" 200 22487
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap.css HTTP/1.1" 500 59
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
return static.serve(request, path, document_root=document_root, **kwargs)
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
return super(StaticFilesHandler, self).__call__(environ, start_response)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
init()
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
File "C:\Python27\lib\mimetypes.py", line 355, in init
self.result = application(self.environ, self.start_response)
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
db.read_windows_registry()
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
return super(StaticFilesHandler, self).__call__(environ, start_response)
return self.serve(request)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
for ctype in enum_types(mimedb):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
response = self.get_response(request)
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
ctype = ctype.encode(default_encoding) # omit in 3.x!
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
return self.serve(request)
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
return serve(request, self.file_path(request.path), insecure=True)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap.min.css HTTP/1.1" 500 59
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
self.result = application(self.environ, self.start_response)
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
return super(StaticFilesHandler, self).__call__(environ, start_response)
init()
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
File "C:\Python27\lib\mimetypes.py", line 355, in init
response = self.get_response(request)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
response = self.get_response(request)
db.read_windows_registry()
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
db.read_windows_registry()
for ctype in enum_types(mimedb):
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return self.serve(request)
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
for ctype in enum_types(mimedb):
ctype = ctype.encode(default_encoding) # omit in 3.x!
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
ctype = ctype.encode(default_encoding) # omit in 3.x!
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap-responsive.min.css HTTP/1.1" 50
0 59
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
mimetype, encoding = mimetypes.guess_type(fullpath)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap-responsive.css HTTP/1.1" 500 59
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
db.read_windows_registry()
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap.min.js HTTP/1.1" 500 59
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap.js HTTP/1.1" 500 59
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
not in range(128)
[08/Jun/2012 03:40:29] "GET /bootstrap/bootstrap.min.js HTTP/1.1" 500 59
Updated 8 June 2012, 9:01 by Toni.