Skip to content

Commit

Permalink
blog model fixed.
Browse files Browse the repository at this point in the history
- backref is working.
- compatible with production database.
  • Loading branch information
nimaafshar79 committed Jun 10, 2020
1 parent a6b7a63 commit 0b65ea0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ def temp_main_function():
}

app.register_blueprint(calculator)
app.register_blueprint(blog)
app.register_blueprint(users)
app.register_blueprint(foods)
app.register_blueprint(blog)


db.init_app(app)
migrate.init_app(app)
Expand Down
2 changes: 1 addition & 1 deletion blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class Post(db.Model):
content = Column(Text, nullable=False, unique=False)
slug = Column(String(128), nullable=False, unique=True)
category = Column(String(256), nullable=True, unique=False)
authorId = Column('author', Integer(), ForeignKey('users.id'), nullable=False)
authorId = Column('authorid', Integer(), ForeignKey('users.id'), nullable=False)
3 changes: 2 additions & 1 deletion users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from werkzeug.security import check_password_hash, generate_password_hash

from extentions import db

from blog.models import Post
from flask_admin.contrib.sqla import ModelView


Expand All @@ -20,6 +20,7 @@ class User(db.Model):
Confirmed = Column(Boolean(), nullable=False, default=False) # Confirmed Email Address Or Not
ConfirmedOn = Column(DateTime(), nullable=True)
FoodSet = db.relationship('Food', backref='author', lazy=True)
PostSet = db.relationship('Post', backref='writer', lazy=True)

def __init__(self, full_name, email, password, admin=False,
registerd_on=None, confirmed=False, confirmed_on=None):
Expand Down

0 comments on commit 0b65ea0

Please sign in to comment.