I need to set a default value to a ForeignKey after the model has been migrated. Is this possible? For instance, a "meal" Class has a ForeignKey named "drinks". Some drinks are added, Pepsi, Coke,.. to the drink table. In the meal Class is it possible to name Coke as the default? From the docs I see only that the index can be used. That implies that I would have to ensure that I added the correctly named default into the correct index. Then I would be stuck with it hard coded in. How is it done so that changes to the default can be done after the fact? An example would be great if anyone has one handy. Best regards.
Asked
Active
Viewed 34 times
0
-
The answers to this question might help - https://stackoverflow.com/questions/9311996/setting-default-value-for-foreign-key-attribute – MattRowbum Jun 22 '21 at 03:17