[pyar] [django] agregar un campo "ficticio" al queryset

Marcos Moyano marcos en anue.biz
Mar Sep 28 15:31:12 ART 2010


class MyModel(models.Model):
    name = models.blablabla

    def cantidad(self):
        return "This goes to list display"
    cantidad.short_description = u"Column title for list_display table
header"

class MyModelAdmin(admin.ModelAdmin):
    class Meta:
        list_display = ('name', 'cantidad')


SaluT
Marcos

2010/9/28 xavier lesa <xavierlesa en gmail.com>

> podrias cambiar
>
> en el list_display (... 'cantidad')
>
> por
>
> def get_cantidad(self):
>     return 'algo'
>
>
> en el list_display (... 'get_cantidad')
>
>
>
> Xavier Lesa
>
> Desarrollo y Tecnología
> Personal: +11 15 3868 3918
> Skype: xavierlesa
> twitter: @xavierlesa
>
>
>
> 2010/9/28 Daniel <dmlistapython en gmail.com>
>
> Gente, hace un tiempo estoy intentando agregar un campo "inventado"
>> (léase que no está en el modelo)
>> a una lista_editable del admin
>> Me sugirieron (acá) que agregue el campo en el form
>> lo hice de esta manera
>> http://pastebin.com/PF7V3vRt
>>
>> pero obtengo:
>> Exception Value:        articuloAdmin.list_display[2], 'cantidad()' is not
>> a callable or an attribute of 'articuloAdmin' or found in the model
>> 'articulo'.
>>
>>
>> cuando lo pongo en el list_display,
>> cuando lo saco de ahí, edito el un registro y aparece el campoo
>> Pero no puedo agregarlo en la lista_editable
>>
>> ¿alguna idea?
>>
>> Daniel Malisani
>> _______________________________________________
>> pyar mailing list pyar en python.org.ar
>> http://listas.python.org.ar/listinfo/pyar
>>
>> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>>
>
>
> _______________________________________________
> pyar mailing list pyar en python.org.ar
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>



-- 
Some people, when confronted with a problem, think “I know, I'll use regular
expressions.” Now they have two problems.

Jamie Zawinski, in comp.emacs.xemacs
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20100928/f77f57c5/attachment.html>


More information about the pyar mailing list