I'm using Django 1.6. I am trying to work out whether there is a way to set a default for the option that appears in a dropdown box on the admin site (rather than the blank ------ option that appears). Specifically I am working with dropdown boxes for foreign keys, so they have no "choice" field.
U may try
in models.py :
foreign_key_field = models.ForeignKey("keyname", default=1)
which shows the first record in all comboboxes. U may change default=1 to any id that u want to show.
I'm using Django 1.6. I am trying to work out whether there is a way to set a default for the option that appears in a dropdown box on the admin site (rather than the blank ------ option that appears). Specifically I am working with dropdown boxes for foreign keys, so they have no "choice" field.
U may try
in models.py :
foreign_key_field = models.ForeignKey("keyname", default=1)
which shows the first record in all comboboxes. U may change default=1 to any id that u want to show.
0 commentaires:
Enregistrer un commentaire