You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I defined a one-to-one relationship for models User and Profile using uselist=False, and registered each model with superadmin. After inserting one data in each model, and creating one-to-one link, when I browse http://127.0.0.1:5000/admin/user/1/, I get this error "TypeError: argument of type 'Profile' is not iterable".
This flask app can be run to reproduce this error.
from flask import Flask
from flask.ext.superadmin import Admin
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///superadmin.db"
app.config["SECRET_KEY"] = "bug"
admin = Admin(app)
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(64), nullable=False, unique=True)
password = db.Column(db.String(64))
fullname = db.Column(db.String(64))
def __repr__(self):
return "<User: %s>" % self.fullname
class Profile(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
user = db.relationship("User", backref=db.backref("profile", uselist=False))
def __repr__(self):
return "<Profile: %s>" % self.user
db.create_all()
# Create Admin views
for model in [User, Profile]:
admin.register(model, session=db.session)
app.run(debug=True)
The text was updated successfully, but these errors were encountered:
Hi,
I defined a one-to-one relationship for models User and Profile using uselist=False, and registered each model with superadmin. After inserting one data in each model, and creating one-to-one link, when I browse http://127.0.0.1:5000/admin/user/1/, I get this error "TypeError: argument of type 'Profile' is not iterable".
This flask app can be run to reproduce this error.
The text was updated successfully, but these errors were encountered: