I am wondering if there is a way to use a list that is stored in a foreignkey as the choices for a charfield.
Here is what I have right now but it is not working.
priority = models.ForeignKey(SLAs)
prioritylevel = models.CharField(choices=priority.details)
It says that the ForeignKey has no attribute 'details'
If this has been answered, please point me the correct direction.
Thanks :)
I think you want use this in forms?
So you can do smth like this:
class MyForm(forms.ModelForm):
prioritylevel = forms.ModelChoiceField(queryset=OtherModel.objects.values('level'))
and in model this will just CharField. It this solve your problem?
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