[Answered ]-Model form not rendering in django template

1👍

Your UploadPhotosForm is inherited from forms.Form(...)
class which does not contain model in Meta class so instead of inheriting from forms.Form class inherit from form.ModelForm(...)

here is final version of your code

 class UploadPhotosForm(forms.ModelForm):
     class Meta:
         model = Photos
         fields = '__all__'

0👍

I found the answer in models.py it should be forms.ModelForm

class UploadPhotosForm(forms.ModelForm):
    class Meta:
        model = Photos
        fields = '__all__'

it is not rendering unless it is a ModelForm

Leave a comment