Django UnicodeDecodeError at /member/user_locations/ 'utf8' codec can't decode byte 0xcf in position 743: invalid continuation byte?

Good day!

In all files is: # -*- 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="Location", default=u")
 types = models.ManyToManyField(LocationType)
 equipment = models.ManyToManyField(Equipment)
 visit_times = models.ManyToManyField(VisitTime)
 keywords = models.CharField(max_length=100, verbose_name="Key words", default=u")
 description = models.TextField(null=True, blank=True)

 def __unicode__(self):
 return self.name


views.py:

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) 
 # here PyCharm complains and says that the unresolved attribute reference 'request'

 return a queryset


urls.py:

url(r'^member/user_locations/$', UserLocationsListView.as_view(), name='user_locations'),


user_locations.html:

{% 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 %}


Traceback:

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


Thank you!!!
July 9th 19 at 13:08
1 answer
July 9th 19 at 13:10
Try
def __unicode__(self):
 return u"{}".format(self.name)
no.. did not help.. but thanks! ) - Mackenzie.Pfannersti commented on July 9th 19 at 13:13
And if so:
verbose_name=u"Location" - morris.Dickens commented on July 9th 19 at 13:16
thank you! problem solved... for some strange reason was a dummy template... intuitive rewrote it again... one to one as it was...and the error is gone :) - Mackenzie.Pfannersti commented on July 9th 19 at 13:19

Find more questions by tags Django