tickets_full: 3412

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
3412 2007-02-01 12:31:26 2007-02-12 03:16:10 2019-06-24 00:51:35.020685 Accepted closed Forms     master fixed Search unicode string in DB I try to search records in my DB and the information I give contains non-ascii characters. I used {{{__icontains}}} for the search. This leads to a unicode error in django. This is the View that is used to search into DB: ---- {{{ def search_entreprise(request): form = EntrepriseSearchForm() if request.method=='POST': new_data = request.POST.copy() form = EntrepriseSearchForm(new_data) if form.is_valid(): data = form.clean_data entreprise_list = Entreprise.objects.all() if data['domaine']: entreprise_list=entreprise_list.filter(domaine=data['domaine']) if data['entrepriseMere']: entreprise_list=entreprise_list.filter(entrepriseMere=data['entrepriseMere']) if data['nom']: entreprise_list=entreprise_list.filter(nom__icontains=data['nom']) return render_to_response('stagesECL/entreprise_list.html',{'list':entreprise_list,}) return render_to_response('stagesECL/entreprise_search.html',{'form':form,}) }}} ---- where in this case the only information given is the entreprise name (nom) which had the value "hé". Here is the error I get: ---- {{{ UnicodeEncodeError at /entreprise/search/ 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128) Request Method: POST Request URL: http://localhost/entreprise/search/ Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128) Exception Location: c:\Python25\lib\site-packages\django\db\models\fields\__init__.py in , line 25 }}} ---- And finally this is the backtrace: ---- {{{ Traceback (most recent call last): File "c:\Python25\lib\site-packages\django\template\__init__.py" in render_node 712. result = node.render(context) File "c:\Python25\lib\site-packages\django\template\defaulttags.py" in render 100. len_values = len(values) File "c:\Python25\lib\site-packages\django\db\models\query.py" in __len__ 100. return len(self._get_data()) File "c:\Python25\lib\site-packages\django\db\models\query.py" in _get_data 430. self._result_cache = list(self.iterator()) File "c:\Python25\lib\site-packages\django\db\models\query.py" in iterator 171. select, sql, params = self._get_sql_clause() File "c:\Python25\lib\site-packages\django\db\models\query.py" in _get_sql_clause 444. joins2, where2, params2 = self._filters.get_sql(opts) File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql 574. joins2, where2, params2 = val.get_sql(opts) File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql 622. return parse_lookup(self.kwargs.items(), opts) File "c:\Python25\lib\site-packages\django\db\models\query.py" in parse_lookup 743. joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) File "c:\Python25\lib\site-packages\django\db\models\query.py" in lookup_inner 915. params.extend(field.get_db_prep_lookup(lookup_type, value)) File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py" in get_db_prep_lookup 172. return ["%%%s%%" % prep_for_like_query(value)] File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py" in 25. prep_for_like_query = lambda x: str(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_") UnicodeEncodeError at /entreprise/search/ 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128) }}} adrian Sébastien ( khepin@gmail.com ) unicode 0 1 0 1 0 0
Powered by Datasette · Query took 3.813ms