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

None of these throw an error but neither do they populate the presented_by 
field. Any ideas?

Thanks

Dave

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c49ae9cc-0911-4ee2-b863-d867afe5f843%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to