Re:Dynamic Django Models with Model Models
by spapas82 on Wednesday August 22, 2018 @10:07AM
(#17818745)
Well, the original article doesn't actually mention ForeignKeys that's why I written may (it only has TextField and IntegerField). Of course nothing stops you from extending them; you'll need to of course add the model where you'll want to create an FK to.
So the MakeField model will have an optional field to denote the class to which you want to create the FK; probably an FK to ContentType would suffice for this field (https://docs.djangoproject.com/en/2.1/ref/contrib/contenttyp...).
I know I've written field and FK too many times, I hope it makes sense; if it doesn't tell me and I'll provide a more thorough example.