Unable to access some fields

Hello i have a question
I have two models

class Names(models.Model):

    name= models.CharField(("Name"), max_length=50)
    status= models.CharField(("Person Status"), max_length=50)
class GeneralForm(models.Model):
    user= models.ForeignKey(Names, verbose_name=("User"), on_delete=models.CASCADE)
... other fields

and have modelForm for GeneralForm in form.py:

class GeneralModelForm(forms.ModelForm):
    class Meta:
        model = GeneralForm
        fields = "__all__"

When i use GeneralModelForm it prints out everything as expected, i see Names model’s name field as select option in template but i also want to see Names model’s status field as select option in template. How can i do that?

You’re misinterpreting what you’re seeing.

What you’re seeing in the select for user is the output of the __str__ function for the Names model. The select itself is to alter the user field - changing which instance of Names that GeneralForm is referring to.

If you want a form to edit Names, then you need to create a ModelForm for Names, and use in your view.

1 Like