python - Linux Only 'ascii' codec can't encode character u'\u0161' in position 3: ordinal not in range(128) -
i encountered error, happens on linux server apache2 running wsgi on django. development in windows copy on linux server.
i see problem in string: (bold part marked django)
društvo tabornikov - rod srnjak logatec
but error happens on 1 page. same string used on settings page displays properly. same error pops on admin page. in views.py file have set utf-8 encoding. error doesn't happen if start server without apache with:
python3 manage.py runserver 0.0.0.0:8000
trace:
environment: request method: request url: https://***.***.**/vodnik/eposta/?cid=17 django version: 1.10.3 python version: 2.7.12 installed applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'vodnik', 'schedule', 'djangobower'] installed middleware: ['django.middleware.security.securitymiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware'] template error: in template /var/www/etaborniki/templates/vodnik/eposta.html, error @ line 59 ascii 49 : <small style="text-align: justify"><strong>opomba:</strong> na dno sporočila bodo avtomatsko dodani podatki roda in 50 : obrazložitev namena 51 : sporočila, ker je naša aplikacija skladna z zakonom <a href="https://www.uradni-list.si/1/content?id=111442">zekom-1</a>. 52 : </small> 53 : <br/> 54 : <small style="text-align: justify"><strong>soglasje:</strong> s pritiskom na gumb pošlji se z navedenim popolnoma 55 : strinjam in prevzemam vso 56 : odgovornost. v sporočilu ne smem posredovati kakršnihkoli osebnih podatkov, sovražnega govora ali vsiljene 57 : pošte. strinjam se, da bo moj e-naslov razviden prejemniku in družbi ksoft.si. sporočila se hranijo 3 mesece. 58 : kršitev tega soglasja ali zakonov zekom-1, zept in zvop-1, se lahko sodno preganja. za katerokoli kršitev družba 59 : ksoft.si in {{ rod_ime }} ne odgovarjata. 60 : </small> 61 : </div> 62 : 63 : {% include 'generic/scripts.html' %} 64 : {% include 'generic/tinymce.html' %} 65 : </body> 66 : </html> 67 : traceback: file "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) file "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _legacy_get_response 249. response = self._get_response(request) file "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) file "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) file "/var/www/etaborniki/vodnik/views.py" in eposta 177. return render_to_response('vodnik/eposta.html', c) file "/usr/local/lib/python3.5/dist-packages/django/shortcuts.py" in render_to_response 21. content = loader.render_to_string(template_name, context, using=using) file "/usr/local/lib/python3.5/dist-packages/django/template/loader.py" in render_to_string 68. return template.render(context, request) file "/usr/local/lib/python3.5/dist-packages/django/template/backends/django.py" in render 66. return self.template.render(context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render 208. return self._render(context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in _render 199. return self.nodelist.render(context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render 994. bit = node.render_annotated(context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_annotated 961. return self.render(context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render 1050. return render_value_in_context(output, context) file "/usr/local/lib/python3.5/dist-packages/django/template/base.py" in render_value_in_context 1028. value = force_text(value) file "/usr/local/lib/python3.5/dist-packages/django/utils/encoding.py" in force_text 80. s = six.text_type(bytes(s), encoding, errors) exception type: unicodeencodeerror @ /vodnik/eposta/ exception value: 'ascii' codec can't encode character u'\u0161' in position 3: ordinal not in range(128)
the error shows have python 2.7 active
... django version: 1.10.3 python version: 2.7.12 installed applications: ...
so since seem run development server python3
assume want same live version.
Comments
Post a Comment