In my django app, especially on the admin side, I do a few def's with my models:
def get_flora(self):
return self.flora.all()
def targeted_flora(self):
return u"%s" % (self.get_flora())
whereas flora is a ManyToManyField, however, sometimes ForeignKey fields are used also.
I do this to provide a utility 'get' function for the model, and then the second def is to provide django admin with a a friendlier field name to populate the tabular/list view.
Perhaps a two part question here: 1. Is this a good workflow/method for doing such things, and 2. The resultant string output in admin looks something like:
[<Species: pittosporum>, <Species: pinus radiata>]
Naturally enough, but how to make it look like:
pittosporum & pinus radiata
or, if there were three;
pittosporum, pinus radiata & erharta ercta
Super thanks!