0

I have been trying to use the AbstractUser to add on a few fields to the standard django user. However while going through the motions, I came across a issue. When I tried to make my migrations a "Value Error: too many values to unpack" would result.

Here is my code:

models.py

class TeamMember(AbstractUser):
    YEAR_LEVELS = (
            ('1', '1st'),
            ('2', '2nd'),
            ('3', '3rd'),
            ('4', '4th'),
            ('5', '5th'),
            ('0', 'Other'),
    )

    SAILING_LEVELS = (
            ('1', 'Beginner'),
            ('2', 'Intermediate'),
            ('3', 'Race'),
    )
    year_level = models.CharField(max_length = 1, choices=YEAR_LEVELS)
    sailing_level = models.CharField(max_length = 1, choices=SAILING_LEVELS)
    board_pos = models.CharField(max_length = 50)
    avatar = models.URLField()

settings.py

AUTH_USER_MODEL = 'main.models.Users'
SOCIAL_AUTH_USER_MODEL = 'main.models.TeamMember'

I am also using python-social-auth which is what the second line in the settings.py file is for.

Shwiby
  • 121
  • 7
  • 2
    when you get an exception, such as _"Value Error: too many values to unpack"_, Python tells you the lines in the files where the error occurred. This is the starting point for solving the problem, no one can help you if you don't share those details. – Anentropic Dec 29 '15 at 04:42
  • 1
    I would not mess up with AbstractUser. Just bind Teammember model via OneToOne to Django's normal user model. – doniyor Dec 29 '15 at 06:09
  • I add ``from .models import User``, and change it to ``AUTH_USER_MODEL = 'main.Users'`` to fix this. – Kane Blueriver Jan 21 '16 at 09:12

2 Answers2

0

In Django package, django/db/models/utils.py takes a model or a string of the form "app_label.ModelName" and returns a corresponding ("app_label", "modelname") tuple. It unpacks with the code:

app_label, model_name = model.split(".").

Now your AUTH_USER_MODEL is 'main.models.Users'. While model.split(".") executes, list has three elements and assignment is going for two variables i.e. app_label and model_name.

Try to give AUTH_USER_MODEL "Users.User" according to ("app_label", "modelname").

Gunjan
  • 986
  • 9
  • 10
0

i built a AUTH_USER_MODEL and i had this error:

app_label, model_name = model.split(".")

the error was the route, i have my applications inside the apps folder, my AUTH_USER_MODEL is:

AUTH_USER_MODEL = 'user.User'