Here the code:

class Download(models.Model):
    """ Disponibilização de arquivos para download """

    descricao =
models.CharField(verbose_name='Descrição',maxlength=250)
    data_do_arquivo = models.DateField()
    caminho_do_arquivo = models.CharField(maxlength=400)
    atualizar_versao_com_grupo =
models.BooleanField(verbose_name='Controlar a versão pelo sistema
principal')
    versao = models.CharField(verbose_name='Versão do
Arquivo',blank=True,null=True,maxlength=20)
    usuarios_permitidos =
models.ManyToManyField(User,blank=True,null=True,filter_interface=models.HORIZONTAL)
    restringir_por_usuario = models.BooleanField(default=False)
    ordem = models.IntegerField(blank=True,null=True,default=0)

    def __str__(self):
        return self.descricao

    def download_restrito(self,usuario):
        try:
            usuario = self.usuarios_permitidos.get(username=usuario)
        except:
            usuario = None
        return (not self.restringir_por_usuario or usuario)


    class Admin:
        list_display = ('descricao','versao','caminho_do_arquivo')
        list_filter = ('versao',)
        search_fields = ('descricao',)
        ordering = ('ordem','descricao',)
        list_per_page = 20

    class Meta:
        ordering = ('ordem','descricao',)


There's more issues about Unicode error on another application that
never occured with Lighttpd. I am afraid that's something about
mod_python.


Regards,


Anderson

On 30 ago, 19:06, Michael Radziej <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 30, Anderson Santos wrote:
>
> > I am still having this issue.
> > I have in my settings DEFAULT_CHARSET = "utf-8", and I created a new
> > database with UTF-8 encoding (using PGAdmin).
> > So I go to admin page, click on my model and then the "add" button, I
> > include a special char (á, ç, etc) and I get a Unicode error on both,
> > Linux and Windows.
>
> > The error message on Linux is:
>
> > 'utf8' codec can't decode bytes in position 1-2: unexpected end of
> > data
>
> > The error message on Windows is:
>
> > 'utf8' codec can't decode bytes in position 1-3: invalid data
>
> > The problem is, it DOES saves the data and displays correctly on the
> > listing admin page for the model. The error only occurs when I try to
> > edit, on display. If the record don't have any special char, it works
> > correctly.
>
> > Both occurs on force_unicode procedure
>
> > When I try to add from manage.py shell onlinux (with or without
> > special chars), it raises an error "SET client_encoding to 'UNICODE'"
> > in  django/db/backends/postgresql/base.py
>
> > I really have no clue why it's happening. I just updated from svn so I
> > have the latest django.
>
> > Any help will be really appreciate
>
> Can you please post the model class, including (if present) __unicode__()
> and __str__() functions?
>
> Michael
>
> --
> noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
> Tel +49-911-9352-0 - Fax +49-911-9352-100http://www.noris.de- The 
> IT-Outsourcing Company
>
> Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk -
> Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689


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

Reply via email to