В настоящее время я работаю над своим административным интерфейсом для веб-сайта. Однако, когда я тестирую добавление нового пользователя, я получаю следующую трассировку:
Traceback (most recent call last):
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1701, in __call__
return self.wsgi_app(environ, start_response)
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1689, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1687, in wsgi_app
response = self.full_dispatch_request()
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1360, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1358, in full_dispatch_request
rv = self.dispatch_request()
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask/app.py", line 1344, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask_peewee/auth.py", line 170, in login
form.password.data,
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask_peewee/auth.py", line 128, in authenticate
if not user.check_password(password):
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask_peewee/auth.py", line 25, in check_password
return check_password(password, self.password)
File "/home/cody/Documents/Flask/SUPRacing/flask/lib/python2.7/site-packages/flask_peewee/utils.py", line 138, in check_password
salt, hsh = enc_password.split('$', 1)
ValueError: need more than 1 value to unpack
Вот код для различных связанных областей моей программы: model.py
class User(db.Model):
id = IntegerField(primary_key=True)
username = CharField()
password = CharField()
email = CharField(120)
admin = BooleanField(default=False)
active = BooleanField(default=True)
# Flask-Login integration
def is_authenticated(self):
return True
def is_active(self):
return True
def is_anonymous(self):
return False
def get_id(self):
return self.id
# Required for administrative interface
def __unicode__(self):
return self.username
def __repr__(self):
return '<User %r>' % (self.username)
app.py
class UserView(ModelAdmin):
columns = ('username', 'email', 'admin', 'active')
filter_exclude = ('id', 'password')
exclude = ('id')
Я уверен, что упускаю что-то очевидное, но я решил опубликовать это на случай, если это не так. Если да, то что я здесь делаю не так?
Вот несколько скриншотов того, как выглядит интерфейс администратора, когда я это делаю.
flask.auth.BaseUser
, а ваша нет. - person Carl Groner   schedule 21.05.2014