Hide a field from a django modelform
If you don't intend on the address_id
field to be edited at all in the form, you should use the exclude
meta field as documented in Using a subset of fields in the form.
The result should look like:
class PharmForm(ModelForm):
class Meta:
model = PharmInfo
exclude = ('address_id',)
Note that this will prevent the address_id
field from being set through the form (check the note under the example in the docs).