Hi,
I have two fields in a model as follows:
society_rowid = models.ForeignKey (
'Organisation', on_delete=models.PROTECT, related_name='society',
blank=True, null=True, db_column='society_rowid',
limit_choices_to={'type': 'whatson_society'},
verbose_name='Society',
)
presented_by = models.CharField (
max_length=50,
blank=True,
)
In the admin interface, if the foreign key is selected and the presented_by is empty, then i want to populate presented_by with the value of the name field at the other end of the relationship. I've tried the following in my clean method for the child object.
if self.society_rowid is not None and self.presented_by is None:
self.presented_by = str ( self.society )
if self.society_rowid is not None and self.presented_by is None:
self.presented_by = self.society__name
if self.society_rowid is not None and self.presented_by is None:
self.presented_by =
self.society.nameNone of these throw an error but neither do they populate the presented_by field. Any ideas?
Thanks
Dave