The str object does not have the META attribute when creating ModelForm in django

I am trying to create a ModelForm with the following code snippet. I get this error. The str object does not have a META attribute. Why is this? Thanks

In my_app / forms.py

from django.contrib.auth.models import User from django.forms import ModelForm class UserProfileForm(ModelForm): class Meta: model = User 

In may_app / views.py

 def u(request): form = UserProfileForm() return render('/projects/templates/form.html',{'form':form}) 
+6
source share
2 answers
 def u(request): form = UserProfileForm() return render(request,'/projects/templates/form.html',{'form':form}) 
+11
source

this means that you pass the line where it expects something else, for example, I got the same error for writing

model = 'User'

but your sample looks fine, so it may not be so ...

and just btw: django has a general look for login pages like this

0
source

Source: https://habr.com/ru/post/893018/


All Articles