Is there a way to get the foreign key type of the model my key relates to? Currently, I'm trying something like:
def __init__(self, *args, **kwargs):
super(JobOrderSupplementForm, self).__init__(*args, **kwargs)
for field in self.fields:
if type(self.fields[field]) == TypedChoiceField:
fieldOption = <Whatever type key points to>.get(id=self.__dict__['initial'][field])
if not fieldOption.isActive:
...Do something to the choices...
I'm trying to programmatically set the available choices that will be shown in my form. So far, I've only been able to figure out that this snippet below gets me some sort of relation to the Foreign Key object...
self.fields[field].__dict__['coerce']
>>> <bound method ForeignKey.to_python of <django.db.models.fields.related.ForeignKey object at 0x01609EF0>>
Any help would be greatly appreciated.