/createuser/ 处的 ValueError 以 10 为底的 int() 的无效文字:'satya'
ValueError at /createuser/ invalid literal for int() with base 10: 'satya'
我正在尝试创建用户。首先,我正在检查用户是否存在,但这是第一次给我这个错误:
ValueError at /createuser/
invalid literal for int() with base 10: 'satya'
当我刷新此页面时工作正常。
我的代码:
for i in range(0, len(username)):
try:
print(username[i])
user = User.objects.get(username = username[i])
except User.DoesNotExist:
user = User.objects.create_user(username=username[i], email=email[i], password=password[i],first_name=firstname[i],last_name=lastname[i] )
group.user_set.add(username[i])
except ValueError:
pass
提前致谢!!
我认为你需要做
group.user_set.add(user.id)
我正在尝试创建用户。首先,我正在检查用户是否存在,但这是第一次给我这个错误:
ValueError at /createuser/
invalid literal for int() with base 10: 'satya'
当我刷新此页面时工作正常。 我的代码:
for i in range(0, len(username)):
try:
print(username[i])
user = User.objects.get(username = username[i])
except User.DoesNotExist:
user = User.objects.create_user(username=username[i], email=email[i], password=password[i],first_name=firstname[i],last_name=lastname[i] )
group.user_set.add(username[i])
except ValueError:
pass
提前致谢!!
我认为你需要做
group.user_set.add(user.id)