Answer the question
In order to leave comments, you need to log in
Django - UnicodeDecodeError at /member/user_locations/ 'utf8' codec can't decode byte 0xcf in position 743: invalid continuation byte?
Good afternoon!
All files have: # -*- coding:utf-8 -*-
models.py:
from django.contrib.auth.models import User
class Location(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100, verbose_name="Локация", default=u'')
types = models.ManyToManyField(LocationType)
equipment = models.ManyToManyField(Equipment)
visit_times = models.ManyToManyField(VisitTime)
keywords = models.CharField(max_length=100, verbose_name="Ключевые слова", default=u'')
description = models.TextField(null=True, blank=True)
def __unicode__(self):
return self.name
class UserLocationsListView(ListView):
model = Location
context_object_name = 'user_locations'
template_name = "user_locations.html"
paginated_by = 10
def get_queryset(self):
queryset = super(UserLocationsListView, self).get_queryset()
queryset = queryset.filter(user=self.request.user)
# здесь PyCharm ругается и говорит что unresolved reference attribute 'request'
return queryset
url(r'^member/user_locations/$', UserLocationsListView.as_view(), name='user_locations'),
{% load staticfiles %}
{% block content %}
<div class="container">
<div class="row user-locations">
<div class="col-md-6 col-md-offset-3">
{% for user_location in user_locations %}
<h3><a href="#">{{ user_location.name }}</a></h3>
{% endfor %}
</div>
</div>
</div>
{% endblock %}
Exception Type: UnicodeDecodeError
Exception Value: 'utf8' codec can't decode byte 0xcf in position 743: invalid continuation byte
Exception Location: C:\commercial_projects\fl\lib\codecs.py in decode, line 314
Unicode error hint
The string that could not be encoded/decoded was: ink">������
Traceback Switch to copy-and-paste view
C:\commercial_projects\fl\lib\site-packages\django\core\handlers\base.py in get_response
response = response.render() ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\response.py in render
self.content = self.rendered_content ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\response.py in rendered_content
template = self._resolve_template(self.template_name) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\response.py in _resolve_template
new_template = self.resolve_template(template) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\response.py in resolve_template
return loader.select_template(template, using=self.using) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\loader.py in select_template
return engine.get_template(template_name, dirs) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\backends\django.py in get_template
return Template(self.engine.get_template(template_name, dirs)) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\engine.py in get_template
template, origin = self.find_template(template_name, dirs) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\engine.py in find_template
source, display_name = loader(name, dirs) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\loaders\base.py in __call__
return self.load_template(template_name, template_dirs) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\loaders\base.py in load_template
template_name, template_dirs) ...
▶ Local vars
C:\commercial_projects\fl\lib\site-packages\django\template\loaders\filesystem.py in load_template_source
return fp.read(), filepath ...
▶ Local vars
C:\commercial_projects\fl\lib\codecs.py in decode
(result, consumed) = self._buffer_decode(data, self.errors, final) ...
▶ Local vars
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question