Wow, sorry, I copied paste and didn't see the font was so awful! 2007/1/31, Sebastien Armand [Pink] <[EMAIL PROTECTED]>: > > So the exact unicode error is: > > 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 > > with the following traceback: > > 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) > > ___________________________________________ > And finally, here's my search view: > > 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é". > > I tried to change the encoding in the html but this doedn't seem to > help.... > Hope somebody knows how to do this! > > 2007/1/31, Kenneth Gonsalves <[EMAIL PROTECTED]>: > > > > > > > > On 30-Jan-07, at 6:26 PM, Sebastien Armand [Pink] wrote: > > > > > Example with a school and a student class. Each student has a > > > foreign key linking to the school where he studies. Through a form, > > > I get the informations to create the student including the school's > > > id. When I want to create and save the student, am I obliged to > > > first hit the database to get the school object and then pass it to > > > student(school=school_object) or is there a way to just use the ID > > > as it is? > > > > in the database django stores this as school_id - and when you save > > you can use that by specificaly setting school_id on the save instead > > of school where django will automatically get and insert the id > > > > -- > > > > regards > > kg > > http://lawgon.livejournal.com > > http://nrcfosshelpline.in/web/ > > > > > > > > > > > > >
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---