In Django is there a way to force admin users to choose to fill one of a few ForeignKeys and not more than one?
I have a model something like :
class URL(models.Model):
...
links = models.URLField(_('Google Links'),verify_exists=True,unique=True)
project = models.ForeignKey(Project,blank=True,null=True)
category = models.ForeignKey(Category,blank=True,null=True)
person = models.ForeignKey(ExternalPerson,blank=True,null=True)
...
I want the admin user to choose one of the Foreignkeys project,category or person.
Or should I organize the model differently?
Just some ideas…
I don’t know what you want to do later on with those objects, but have you consider to create a common interface to all of them? It could fix your problem…
If the interface doesn’t suit you,maybe you could create a Form to check that just one of the ForeignKeys have been selected.