I have a fairly simple foreign key relationship displayed by an inline in Django’s admin:
# models
class Profile(models.Model):
name = models.CharField(max_length=30)
class EmailAddress(models.Model):
address = models.EmailField()
is_default = models.BooleanField()
# admins
class ProfileAdmin(admin.ModelAdmin):
class EmailAddressInline(admin.TabularInline):
model = EmailAddress
inlines = (EmailAddressInline,)
I’d simply like to be able to select only one of the email addresses as is_default, using a radio button on the admin page.
Is this possible?
I think this might be a case of a bad design. You should store the id of the default email in the profile table, so you can assure on database and program level that two email addresses for one profile won’t be set to default. Give it a thought to change your database structure.