django.core.exceptions.FieldError: Unknown field(s) (is_admin) specified for freelancer -
models.py
class myusermanager(baseusermanager): def create_user(self, name, skills, password=none): if not name: raise valueerror('users must have unique name ') user = self.model( name=self.name, skills=skills, ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, name, skills, password): """ creates , saves superuser given email, date of birth , password. """ user = self.create_user( name, password=password, skills=skills, ) user.is_admin = true user.save(using=self._db) return user class freelancer(abstractbaseuser, permissionsmixin): name = models.charfield(max_length=20, unique='true') password = models.charfield(max_length=20) field_of_interest = models.charfield(max_length=200) skills = models.textfield() experience = models.textfield() username_field = 'name' required_fields = ['skills'] class meta: verbose_name = _('user') verbose_name_plural = _('users') def get_absolute_url(self): return "/users/%s/" % urlquote(self.name) def get_short_name(self): return self.name def get_full_name(self): return self.name def __str__(self): # __unicode__ on python 2 return self.name # # def has_perm(self, perm, obj=none): # # "does user have specific permission?" # # # simplest possible answer: yes, # return true def has_module_perms(self, applabel): # "does user have permissions view app `app_label`?" # simplest possible answer: yes, return true # @property # def is_staff(self): # # "is user member of staff?" # # "simplest possible answer: admins staf" # return self.is_admin
and exact error i'm getting
file "/usr/lib/python2.7/dist-packages/django/forms/models.py", line 294, in __new__ raise fielderror(message) django.core.exceptions.fielderror: unknown field(s) (is_admin) specified freelancer
i got solution need add these 2 lines in class freelancer here line-- is_active = models.booleanfield(default=true) is_admin = models.booleanfield(default=false)
Comments
Post a Comment