Re: mas sobre unicodedecode erros RESUELTO!

2008-09-11 Thread anonymous

Vaya, se resolvió el problema aparentemente pero me sigue dando
problemas través la shell:

In [59]: Mymodel.objects.all()
Out[59]:
---
UnicodeDecodeErrorTraceback (most recent call
last)

/home/user/myproject/ in ()

/var/lib/python-support/python2.5/IPython/Prompts.pyc in
__call__(self, arg)
549
550 # and now call a possibly user-defined print
mechanism
--> 551 manipulated_val = self.display(arg)
552
553 # user display hooks can change the variable to be
stored in

/var/lib/python-support/python2.5/IPython/Prompts.pyc in
_display(self, arg)
575 return IPython.generics.result_display(arg)
576 except TryNext:
--> 577 return self.shell.hooks.result_display(arg)
578
579 # Assign the default display method:

/var/lib/python-support/python2.5/IPython/hooks.pyc in __call__(self,
*args, **kw)
133 #print "prio",prio,"cmd",cmd #dbg
134 try:
--> 135 ret = cmd(*args, **kw)
136 return ret
137 except ipapi.TryNext, exc:

/var/lib/python-support/python2.5/IPython/hooks.pyc in
result_display(self, arg)
163
164 if self.rc.pprint:
--> 165 out = pformat(arg)
166 if '\n' in out:
167 # So that multi-line strings line up with the left
column of

/usr/lib/python2.5/pprint.pyc in pformat(self, object)
109 def pformat(self, object):
110 sio = _StringIO()
--> 111 self._format(object, sio, 0, 0, {}, 0)
112 return sio.getvalue()
113

/usr/lib/python2.5/pprint.pyc in _format(self, object, stream, indent,
allowance, context, level)
127 self._readable = False
128 return
--> 129 rep = self._repr(object, context, level - 1)
130 typ = _type(object)
131 sepLines = _len(rep) > (self._width - 1 - indent -
allowance)

/usr/lib/python2.5/pprint.pyc in _repr(self, object, context, level)
193 def _repr(self, object, context, level):
194 repr, readable, recursive = self.format(object,
context.copy(),
--> 195 self._depth,
level)
196 if not readable:
197 self._readable = False

/usr/lib/python2.5/pprint.pyc in format(self, object, context,
maxlevels, level)
205 and whether the object represents a recursive
construct.
206 """
--> 207 return _safe_repr(object, context, maxlevels, level)
208
209

/usr/lib/python2.5/pprint.pyc in _safe_repr(object, context,
maxlevels, level)
290 return format % _commajoin(components), readable,
recursive
291
--> 292 rep = repr(object)
293 return rep, (rep and not rep.startswith('<')), False
294

/home/user/myproject/myapp/django/db/models/query.pyc in
__repr__(self)
139
140 def __repr__(self):
--> 141 return repr(list(self))
142
143 def __len__(self):

/home/user/myproject/myapp/django/db/models/base.pyc in __repr__(self)
242
243 def __repr__(self):
--> 244 return smart_str(u'<%s: %s>' %
(self.__class__.__name__, unicode(self).encode('utf-8')))
245
246 def __str__(self):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
23: ordinal not in range(128)


Y lo mismo cuando trato de ejecutar en una función:

model = get_model(app_label, model_name)
queryset = model.objects.all()
fields = queryset.model._meta.admin.list_display

Django me devuelve una página de error:

 �� Local vars
VariableValue
app_label   'myapp'
model   
model_name  u'mymodel'
querysetError in formatting: 'ascii' codec can't decode byte 0xc3 in
position 23: ordinal not in range(128)


On Aug 21, 5:20 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> anonymous wrote:
>
> > Sin DATABASE_OPTIONS se resuelve el problema en mysql!!
>
> > Muchas Gracias!
>
> De nada.
>
> Como dijo Karen, casi no necesita DATABASE_OPTIONS en settings.py.
> Cuando se usa DATABASE_OPTIONS, solo hay que specificar el tipo del
> database engine y no mas. Es posible que hay otros casos que requieren
> otron opciones, pero nunca he visto un projecto que lo usa.
>
> Jeff Anderson
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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: mas sobre unicodedecode erros RESUELTO!

2008-08-21 Thread Jeff Anderson

anonymous wrote:


Sin DATABASE_OPTIONS se resuelve el problema en mysql!!

Muchas Gracias!
  

De nada.

Como dijo Karen, casi no necesita DATABASE_OPTIONS en settings.py. 
Cuando se usa DATABASE_OPTIONS, solo hay que specificar el tipo del 
database engine y no mas. Es posible que hay otros casos que requieren 
otron opciones, pero nunca he visto un projecto que lo usa.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: mas sobre unicodedecode erros RESUELTO!

2008-08-21 Thread anonymous



On Aug 20, 8:05 pm, Jeff Anderson <[EMAIL PROTECTED]> wrote:
> anonymous wrote:
> > Hola,
>
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> > 6: ordinal not in range(128)
>
> 
> > ¿Cómo podría resolverlo?
>
> > La versión de django es svn trunk y la de Mysql es la  5.
>
> Tendría que ver tus modelos antes de ayudar con eso.
>
class Mymodel(models.Model):
name =  models.CharField(_('name'), max_length=50)
description = models.CharField(_('description'),max_length=200,
blank = True, null = True)
def __unicode__(self):
return self.name
class Meta:
verbose_name = _('mymodel')

"name" es el atributo que almacena cadenas con tildes y "ñ".

Syncdb genera la siguiente tabla (dump de mysql):

The mysql table that syncdb generate is (the mysql dump):

DROP TABLE IF EXISTS `demo_mymodel`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `demo_mymodel` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `description` varchar(200) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
SET character_set_client = @saved_cs_client;

> ¿Has probado eso con algo más de Mysql?

No entiendo a qué te refieres.

> No sé si soporte unicode sqlite.

He probado con sqlite y no me da ningún problema

> ¿Sierve eso sin los opciones DATABASE_OPTIONS, o teine la misma problema?
>
Sin DATABASE_OPTIONS se resuelve el problema en mysql!!

Muchas Gracias!
--~--~-~--~~~---~--~~
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: mas sobre unicodedecode erros

2008-08-20 Thread Jeff Anderson

anonymous wrote:

Hola,


UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
6: ordinal not in range(128)
  



¿Cómo podría resolverlo?

La versión de django es svn trunk y la de Mysql es la  5.
  

Tendría que ver tus modelos antes de ayudar con eso.

¿Has probado eso con algo más de Mysql? No sé si soporte unicode sqlite. 
¿Sierve eso sin los opciones DATABASE_OPTIONS, o teine la misma problema?


Disculpa mí español. No lo uso en la computadora mucho.

¡Graciás!

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


mas sobre unicodedecode erros

2008-08-20 Thread anonymous

Hola,

Tengo el siguiente error

In [2]: from myapp.models import *

In [3]: Mymodel.objects.all()
Out[3]:
---
UnicodeDecodeErrorTraceback (most recent call
last)

/home/user/myproject/ in ()

/var/lib/python-support/python2.5/IPython/Prompts.pyc in
__call__(self, arg)
   549
   550 # and now call a possibly user-defined print
mechanism
--> 551 manipulated_val = self.display(arg)
   552
   553 # user display hooks can change the variable to be
stored in

/var/lib/python-support/python2.5/IPython/Prompts.pyc in
_display(self, arg)
   575 return IPython.generics.result_display(arg)
   576 except TryNext:
--> 577 return self.shell.hooks.result_display(arg)
   578
   579 # Assign the default display method:

/var/lib/python-support/python2.5/IPython/hooks.pyc in __call__(self,
*args, **kw)
   133 #print "prio",prio,"cmd",cmd #dbg
   134 try:
--> 135 ret = cmd(*args, **kw)
   136 return ret
   137 except ipapi.TryNext, exc:

/var/lib/python-support/python2.5/IPython/hooks.pyc in
result_display(self, arg)
   163
   164 if self.rc.pprint:
--> 165 out = pformat(arg)
   166 if '\n' in out:
   167 # So that multi-line strings line up with the left
column of

/usr/lib/python2.5/pprint.pyc in pformat(self, object)
   109 def pformat(self, object):
   110 sio = _StringIO()
--> 111 self._format(object, sio, 0, 0, {}, 0)
   112 return sio.getvalue()
   113

/usr/lib/python2.5/pprint.pyc in _format(self, object, stream, indent,
allowance, context, level)
   127 self._readable = False
   128 return
--> 129 rep = self._repr(object, context, level - 1)
   130 typ = _type(object)
   131 sepLines = _len(rep) > (self._width - 1 - indent -
allowance)

/usr/lib/python2.5/pprint.pyc in _repr(self, object, context, level)
   193 def _repr(self, object, context, level):
   194 repr, readable, recursive = self.format(object,
context.copy(),
--> 195 self._depth,
level)
   196 if not readable:
   197 self._readable = False

/usr/lib/python2.5/pprint.pyc in format(self, object, context,
maxlevels, level)
   205 and whether the object represents a recursive
construct.
   206 """
--> 207 return _safe_repr(object, context, maxlevels, level)
   208
   209

/usr/lib/python2.5/pprint.pyc in _safe_repr(object, context,
maxlevels, level)
   290 return format % _commajoin(components), readable,
recursive
   291
--> 292 rep = repr(object)
   293 return rep, (rep and not rep.startswith('<')), False
   294

/usr/lib/python2.5/site-packages/django/db/models/query.pyc in
__repr__(self)
   139
   140 def __repr__(self):
--> 141 return repr(list(self))
   142
   143 def __len__(self):

/usr/lib/python2.5/site-packages/django/db/models/base.pyc in
__repr__(self)
   242
   243 def __repr__(self):
--> 244 return smart_str(u'<%s: %s>' %
(self.__class__.__name__, unicode(self)))
   245
   246 def __str__(self):

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
6: ordinal not in range(128)

La tabla Mymodel tiene registros con tildes como "construcción".
La tabla se creó con  syncdb com " DEFAULT CHARSET=latin1;".
He probado a modificar la tabla como  " DEFAULT CHARSET=utf8" pero
entonces me devuelve una lista vacía.

Cuando Mymodel es un ForeignKey a mi Myothe model ; en la interfaz de
administracción de Myoghermodel en lugar de mostrarme un select, no me
muestra nada.

En  settings.py tengo:
DATABASE_OPTIONS = {'use_unicode': True, 'charset': 'utf8',
"init_command": "SET storage_engine=INNODB", "init_command": "set
names utf8","init_command": "SET character_set_database=utf8",
"init_command": "SET character_set_client=utf8"
}
#DATABASE_OPTIONS = {'use_unicode': False}
FILE_CHARSET = 'utf8'
DEFAULT_CHARSET = 'utf8'
DATABASE_CHARSET =  'utf8'

¿Cómo podría resolverlo?

La versión de django es svn trunk y la de Mysql es la  5.

Gracias por adelantado.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---