Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhandled exception when validating models in Django

I have encountered an error while compiling code for a Django web application that I am writing

In console, it shows:

Validating models...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x028A2BB8>

The error tracking in the console up to where the error is in my program is

File "C:\Uni Work\R&D\yellowProject\teamList\models.py", line 9, in <module>
class UserTeamEntry(models.Model):
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 144, in __new__
new_class.add_to_class(obj_name, obj)
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
TypeError: contribute_to_class() missing 1 required positional argument: 'name'

My models.py:

from django.db import models
from django.contrib.auth.models import User

class UserTeamEntry(models.Model):

    user = models.OneToOneField(User)
    position_choices = (('TEAMMEMBER', 'Team Member'),
                        ('MANAGER', 'Manager'),)
    userID = models.AutoField(primary_key = True)
    userPosition = models.CharField(max_length = 10, choices = position_choices)
    userShare = models.BooleanField
like image 639
B Wong Avatar asked Apr 25 '26 18:04

B Wong


1 Answers

You just forget to add parentheses () after BooleanField. So, add them:

userShare = models.BooleanField()
like image 183
stalk Avatar answered Apr 27 '26 08:04

stalk