[Django]-Django: How to define a dynamic initial value on a ForeignKey Model Field

4👍

Model fields don’t take an “initial” parameter, they take “default”.

1👍

Override the save() method of the model and check if the field’s value is None.

0👍

If I understand you right about the dynamic part, this is related to a Django foreign key FAQ, and James Bennett’s Django tips: auto-populated fields (see The Holy Grail subhead :-).

Leave a comment