Reputation: 29
forms.py
from django import forms
from django.contrib.auth.models import User
from basic_app.models import UserProfileInfo
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
models = User
feilds = ['username','email','password']
class UserProfileInfoForm(forms.ModelForm):
class Meta:
models = UserProfileInfo
feilds = ('portfolio_site','profile_pic')
models.py
from django.db import models
from django.contrib.auth.models import User
class UserProfileInfo(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE)
portfolio_site = models.URLField(blank=True)
profile_pic = models.ImageField(upload_to='profile_pics',blank=True)
def __str__(self):
return self.user.username
As you can see in the above error image, my code is not functioning properly. I have added my forms.py and models.py code. Please help me resolve the issue.
Upvotes: 0
Views: 40
Reputation: 2246
It should be model
instead of models
inside the Meta class of UserForm.
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User # model instead of models here
feilds = ['username','email','password']
Upvotes: 2