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.
Dropdown default can be set by specifying it in the foreign key field in models.py :
foreign_key_field = models.ForeignKey("keyname", default=1)
This will select the record with id=1 in the corresponding admin dropdown by default. You may change default=1 to any id that you want to show.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With