Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

python - Sharing data between models

I am working on a Flask project. I have 2 models, user and status. These are in separate folders with code like so,

class Status(object):
    def __init__(self, username  , email, biography, interests, about, user_id, block_status=False, _id=None):
        self.username = username
        self.email = email
        self.biography = biography
        self.interests = interests
        self.about = about
        self.user_id = user_id
        self.block_status = block_status
        self._id = uuid.uuid4().hex if _id is None else _id

and

class User(object):
    def __init__(self, first_name, last_name, username, email, password, _id=None):
        self.first_name = first_name
        self.last_name = last_name
        self.username = username
        self.email = email
        self.password = password
        self._id = uuid.uuid4().hex if _id is None else _id

I want the user model to share the id attribute to status model. I have tried my way but it did not work.

question from:https://stackoverflow.com/questions/66052537/sharing-data-between-models

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...