apply default_if_none filter type behavior in admin fields?

4 views
Skip to first unread message

Some Guy

unread,
Jul 3, 2009, 6:43:42 PM7/3/09
to Django users
Hi,
I wonder if anyone has ideas about the best way to do this.

My field shows up as (None) in the change_list view on admin. I would
love to have a behavior similar to <a href="http://
docs.djangoproject.com/en/dev/ref/templates/builtins/#default-if-
none">default_if_none</a> template tag.

My Ideas --------------------

1. making a new template just for this seems difficult.

2.I could make a function in the model that returns '' if the actual
field is None...
like

cost = models.DecimalField
def display_cost(self):
if self.cost:
return self.cost
else:
return ' '

But if I wanted to do this for many fields it could get pretty ugly
------------------------------------

What would be the best way of these two? Or is there some way I
haven't thought of?




Some Guy

unread,
Jul 3, 2009, 6:46:18 PM7/3/09
to Django users
Of course it should be default_if_none template tag, but it mangled my
link
Reply all
Reply to author
Forward
0 new messages