Admin: Model ordering and relationship conditional __unicode__ return values?

2011-04-19 Thread Micky Hulse
Hello,

Couple of noob questions:

1.

Is it possible to order the models of my app manually (vs.
alphabetically) when viewing the app page?

See attached "ordering.png".

2.

Relationship models: How can I return different __unicode__ values
based on the relationship that I am viewing.

[code]

class SeasonPlayerRelationship(models.Model):

season = models.ForeignKey('Season')
player = models.ForeignKey('Player')

...

def __unicode__(self):
if self.season:
return 'Season'
else:
return 'Player'

[/code]

See attached "relationship.png".

In the screenshot above, just as an example, I would like "Player" to
get returned, and not "Season".

Optimally, I would like to return nothing for the relationship's
__unicode__, but when I do this:

[code]

def __unicode__(self):
return ''

[/code]

There is just a big gap where a __unicode__ label would appear (I
assume it's because the admin is spitting out an empty  or
).

Thanks!
Micky

-- 
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: Admin: Model ordering and relationship conditional __unicode__ return values?

2011-04-20 Thread Micky Hulse
Hello,

On Tue, Apr 19, 2011 at 1:28 PM, Micky Hulse  wrote:
> 1.
> Is it possible to order the models of my app manually (vs.
> alphabetically) when viewing the app page?
> 2.
> Relationship models: How can I return different __unicode__ values
> based on the relationship that I am viewing.

I think I got everything figured out. I am going to keep the current
ordering of the models and I don't plan on trying to do any sort of
conditional checking in the relationship's __unicode__ return values.
:)

Cheers,
Micky

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