Re: 2 Questions!
1. No, you can create a student with: Student.objects.create(name="Foo Bar", school_id=2) 2. Not sure... I have a Django application here, and when I search for "è", it returns the restaurant "Les Deux Frères" without problems. Could be an encoding problem with your database or with your terminal or with Python. That's the problem with encoding issues: they take a lot of time to figure out and properly fix. Hope this helps. Vincent. On Jan 30, 7:56 am, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]> wrote: > I've been trying Django and have 2 small problems: > > - When I have a foreign key field in a model, is it possible to use just the > id of the foreign object or do we always have to use the object itself? > 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? > > - When I search something in my database, using icontains on a field, it > doesn't work when there are non-asccii characters: a product field may > contain (in french so with accents!!) télévision but when I look for "télé" > I get a unicode error. If I look for "vision" everything works just fine. > Any idea why? > > Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
It helps! I'll check better for the encoding problems... 2007/1/30, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > > 1. No, you can create a student with: Student.objects.create(name="Foo > Bar", school_id=2) > > 2. Not sure... I have a Django application here, and when I search for > "è", it returns the restaurant "Les Deux Frères" without problems. > Could be an encoding problem with your database or with your terminal > or with Python. That's the problem with encoding issues: they take a > lot of time to figure out and properly fix. > > Hope this helps. > > Vincent. > > On Jan 30, 7:56 am, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]> > wrote: > > I've been trying Django and have 2 small problems: > > > > - When I have a foreign key field in a model, is it possible to use just > the > > id of the foreign object or do we always have to use the object itself? > > 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? > > > > - When I search something in my database, using icontains on a field, it > > doesn't work when there are non-asccii characters: a product field may > > contain (in french so with accents!!) télévision but when I look for > "télé" > > I get a unicode error. If I look for "vision" everything works just > fine. > > Any idea why? > > > > Thanks > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
On Tue, 30 Jan 2007 13:56:12 +0100, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]> said: > - When I search something in my database, using icontains on a field, it > doesn't work when there are non-asccii characters: a product field may > contain (in french so with accents!!) télévision but when I look for > "télé" > I get a unicode error. If I look for "vision" everything works just fine. > Any idea why? Sounds like one is a Unicode object and the other an encoded string (maybe UTF-8 or Latin-1). James -- James Tauber http://jtauber.com/ journeyman of somehttp://jtauber.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
As you talk about this, if I remember well, the database is UTF-8 but the web page which contains the form has no encoding declared. May this be the source of troubles? 2007/1/30, James Tauber <[EMAIL PROTECTED]>: > > > > On Tue, 30 Jan 2007 13:56:12 +0100, "Sebastien Armand [Pink]" > <[EMAIL PROTECTED]> said: > > - When I search something in my database, using icontains on a field, it > > doesn't work when there are non-asccii characters: a product field may > > contain (in french so with accents!!) télévision but when I look for > > "télé" > > I get a unicode error. If I look for "vision" everything works just > fine. > > Any idea why? > > Sounds like one is a Unicode object and the other an encoded string > (maybe UTF-8 or Latin-1). > > James > -- > James Tauber http://jtauber.com/ > journeyman of somehttp://jtauber.com/blog/ > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
Sebastien Armand [Pink]: > - When I search something in my database, using icontains on a field, it > doesn't work when there are non-asccii characters: a product field may > contain (in french so with accents!!) télévision but when I look for "télé" > I get a unicode error. If I look for "vision" everything works just fine. > Any idea why? What did you do exactly to search, and what is the exact backtrace? -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
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 -~--~~~~--~~--~--~---
Re: 2 Questions!
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 -~--~~~~--~~--~--~---
Re: 2 Questions!
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 -~--~~-
Re: 2 Questions!
Hi Sebastien, I don't see where the exact problem is and whether there's already a ticket, but this is a bug within the newforms package. It is caused due to newforms putting unicode into the models, but most parts of Django are not unicode ready. You can search in the existing tickets (with category == 'newforms') whether there's already a patch. If not, could you please open a new ticket and provide exactly the information from the mail I'm replying to? If you put {{{ and }}} around the traceback and the code, it won't look as bad as in email (it's always like this in mail). And please put a link to this thread's google archive, if you can. Sebastien Armand [Pink]: > 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("_", "\_") the str(x) throws this exception when x is not an ASCII character. > > UnicodeEncodeError at /entreprise/search/ > 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in > range(128) Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
No problem, thanks! There's already a ticket, it's here: http://code.djangoproject.com/ticket/3387 But though, is there another encoding I could use and how do I specify it? 2007/2/1, Michael Radziej <[EMAIL PROTECTED]>: > > > Hi Sebastien, > > I don't see where the exact problem is and whether there's already a > ticket, but this is a bug within the newforms package. It is caused > due to newforms putting unicode into the models, but most parts of > Django are not unicode ready. You can search in the existing tickets > (with category == 'newforms') whether there's already a patch. > > If not, could you please open a new ticket and provide exactly the > information from the mail I'm replying to? If you put {{{ and }}} > around the traceback and the code, it won't look as bad as in email > (it's always like this in mail). And please put a link to this > thread's google archive, if you can. > > Sebastien Armand [Pink]: > > 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("_", "\_") > > the str(x) throws this exception when x is not an ASCII character. > > > > > UnicodeEncodeError at /entreprise/search/ > > 'ascii' codec can't encode character u'\xe9' in position 1: ordinal > not in > > range(128) > > Michael > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100 > > http://www.noris.de - The IT-Outsourcing Company > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
Sebastien Armand [Pink]: > No problem, thanks! > > There's already a ticket, it's here: > http://code.djangoproject.com/ticket/3387 No, thanks for searching, but it's not. #3387 was triggered by using queryset.filter(unicode_string) You didn't use a unicode_string within filter(), though the traceback is similar. It happened because Django's ORM internal code looks up the related records to a foreign key with filter(), and uses a unicode string because because newforms put it in the model. It's a new bug, but the patch in the #3387 should heal it. Funny. Please *do* open a ticket. #3387 is closed. I'm now pretty sure that your case has not been reported before. > But though, is there another encoding I could use and how do I specify it? Short answer: No, unless you want to patch Django or python ;-) The concept of a default encoding is doomed, and python has finally learned the lesson. I guess that you can use unicode(bytestring) without giving an encoding at all is a trap that stems from times when python had a settable default encoding. ASCII is used as a default encoding in these circumstances. The same applies for str(unicode_string) or for (bytestring == unicode_string). All these are traps, traps, traps. There is a hook in site.py, but this was left in for experiments. If you use it, you'll probably get into devil's kitchen. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
Oooops didn't read enaough from the #3387 ticket. So I'll open one! Thanks a lot for your explanations. 2007/2/1, Michael Radziej <[EMAIL PROTECTED]>: > > > Sebastien Armand [Pink]: > > No problem, thanks! > > > > There's already a ticket, it's here: > > http://code.djangoproject.com/ticket/3387 > > No, thanks for searching, but it's not. #3387 was triggered by using > > queryset.filter(unicode_string) > > You didn't use a unicode_string within filter(), though the > traceback is similar. It happened because Django's ORM internal code > looks up the related records to a foreign key with filter(), and > uses a unicode string because because newforms put it in the model. > > It's a new bug, but the patch in the #3387 should heal it. Funny. > Please *do* open a ticket. #3387 is closed. I'm now pretty sure that > your case has not been reported before. > > > But though, is there another encoding I could use and how do I specify > it? > > Short answer: No, unless you want to patch Django or python ;-) > > The concept of a default encoding is doomed, and python has finally > learned the lesson. I guess that you can use unicode(bytestring) > without giving an encoding at all is a trap that stems from times > when python had a settable default encoding. ASCII is used as a > default encoding in these circumstances. The same applies for > str(unicode_string) or for (bytestring == unicode_string). All these > are traps, traps, traps. > > There is a hook in site.py, but this was left in for experiments. If > you use it, you'll probably get into devil's kitchen. > > > Michael > > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100 > > http://www.noris.de - The IT-Outsourcing Company > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
This time it's done. The ticket is here: http://code.djangoproject.com/ticket/3412 I hope it's enough documented. 2007/2/1, Sebastien Armand [Pink] <[EMAIL PROTECTED]>: > > Oooops didn't read enaough from the #3387 ticket. So I'll open one! > Thanks a lot for your explanations. > > 2007/2/1, Michael Radziej <[EMAIL PROTECTED] >: > > > > > > Sebastien Armand [Pink]: > > > No problem, thanks! > > > > > > There's already a ticket, it's here: > > > http://code.djangoproject.com/ticket/3387 > > > > No, thanks for searching, but it's not. #3387 was triggered by using > > > > queryset.filter(unicode_string) > > > > You didn't use a unicode_string within filter(), though the > > traceback is similar. It happened because Django's ORM internal code > > looks up the related records to a foreign key with filter(), and > > uses a unicode string because because newforms put it in the model. > > > > It's a new bug, but the patch in the #3387 should heal it. Funny. > > Please *do* open a ticket. #3387 is closed. I'm now pretty sure that > > your case has not been reported before. > > > > > But though, is there another encoding I could use and how do I specify > > it? > > > > Short answer: No, unless you want to patch Django or python ;-) > > > > The concept of a default encoding is doomed, and python has finally > > learned the lesson. I guess that you can use unicode(bytestring) > > without giving an encoding at all is a trap that stems from times > > when python had a settable default encoding. ASCII is used as a > > default encoding in these circumstances. The same applies for > > str(unicode_string) or for (bytestring == unicode_string). All these > > are traps, traps, traps. > > > > There is a hook in site.py, but this was left in for experiments. If > > you use it, you'll probably get into devil's kitchen. > > > > > > Michael > > > > > > -- > > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > > Tel +49-911-9352-0 - Fax +49-911-9352-100 > > > > http://www.noris.de - The IT-Outsourcing Company > > > > > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
Sebastien Armand [Pink]: > This time it's done. The ticket is here: > http://code.djangoproject.com/ticket/3412 I hope it's enough documented. Merci! I finally realized that it's not about a ForeignKey, sorry for the confusion. Can you check if you can work around it with a entreprise_list=entreprise_list.filter(domaine=data['domaine'].encode(settings.DEFAULT_CHARSET)) etc.? Hope that helps! Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions!
The patch provided for ticket 3387 works perfectly! 2007/2/1, Michael Radziej <[EMAIL PROTECTED]>: > > > Sebastien Armand [Pink]: > > This time it's done. The ticket is here: > > http://code.djangoproject.com/ticket/3412 I hope it's enough documented. > > Merci! I finally realized that it's not about a ForeignKey, sorry > for the confusion. Can you check if you can work around it with a > > entreprise_list=entreprise_list.filter(domaine=data['domaine'].encode( > settings.DEFAULT_CHARSET)) > > etc.? > > Hope that helps! > > Michael > > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100 > > http://www.noris.de - The IT-Outsourcing Company > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 questions
1. I am not sure about this one. 2. You will also need blank=True in addition to null=True in those nullable fields. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 questions
Thanks RajeshD --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: 2 Questions about feeds
Please try to change the Sitename in the backend at /admin/sites/site/ Per default its example.com On Aug 8, 8:46 pm, When ideas fail wrote: > Hi, i'm developing a feed but i still have a couple of questionss. > > 1. I have this in my models: > > def get_absolute_url(self): > return "/blog/%s/" % self.post_slug > > but the rss has the links down as:http://example.com/blog/post_3/, > the blog/post_3/ is correct, how can i make sure its linked to right > domain name? for example have it go to andrew.com/blog/post_3? > > 2. What does the element do? > I've changed it a few times and i can't see what difference it makes? > > Thanks --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 2 questions about Django
> 1) Can I make a site like this one (http://www.tamarawobben.nl) with > Django. > Till now I find no solution which I can have different numbers of > articles on pages. Yes, of course you can. You can almost do anything with Django as django to put it simply mainly will output HTML Code which is what you want for a webpage. It looks like you are looking for a blogging app for django. Just search for it with your favorite search engine. cheers Ivo -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 2 questions on Model
On Tue, 2008-04-01 at 22:10 -0700, PENPEN wrote: > 1. About select_related(): > It is said that it will automatically "follow" foreign-key > relationships, selecting that additional related-object data when it > executes its query. So it is not applicable for ManyToMany > relationship, isn't it? That's correct. It only follows non-nullable many-to-one relations. > And if select_related() is used, will the queryset method on the > related Manager access the DB later? For example: > b = Book.objects.select_related().get(id=4) > p = b.author # Doesn't hit the database. > p.get(pk=3) # Will this action hit the database? If 'author' is marked as a ForeignKey on the Book model, then b.author is an Author object. So b.author.get() makes no sense. > 2. About iterator(), 'for' and 'enumerate' on queryset: > There is a snippet from the django document page(http:// > www.djangoproject.com/documentation/db-api/): [... snip ...] > It seems that 'for' loop and enumerate on a QuerySet will use its > iterator. Then if I use 'for' loop or enumerate() on a queryset to do > some logical task and in the template it will iterate the QuerySet > again to display all the data, will the database be hit again? Looping over an iterable object does not call the "iterator()" method. It calls the __iter__() method. If you have a look at the definition of __iter__ in query.py, you'll notice that it doesn't call iterator() if the result_cache is populated. Regards, Malcolm -- I've got a mind like a... a... what's that thing called? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---