⚠️ Push biežāk GIT, lai nav tā, ka pēdējā brīdī neko neredzu
object relational mapping
https://docs.sqlalchemy.org/en/20/orm/quickstart.html
xxxxxxxxxx
241from flask import Flask
2from flask_sqlalchemy import SQLAlchemy
3
4app = Flask(__name__)
5app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///mydatabase.db'
6db = SQLAlchemy(app)
7
8class User(db.Model):
9id = db.Column(db.Integer, primary_key=True)
10username = db.Column(db.String(80), unique=True, nullable=False)
11email = db.Column(db.String(120), unique=True, nullable=False)
12
13def __repr__(self):
14return '<User %r>' % self.username
15
16if __name__ == '__main__':
17# Create the database tables
18db.create_all()
19
20# Perform database operations
21# ...
22
23# Run the Flask application
24app.run()
Uztaisīt bez flask_login
Video: https://youtube.com/live/dp9kGvgHuOQ?feature=share
Jamboard: https://jamboard.google.com/d/1qmOj3J4hwlCL4QlzuFIsCeYiCYhB-PnZQBY0haVnvlo/edit?usp=sharing
Template: http://share.yellowrobot.xyz/1629812987-programming-tutorials/session_2.zip
Video: https://youtu.be/6LV6df_JWbs
Jamboard: https://jamboard.google.com/d/1ZrLZ2_WvgmvVBRsponJ8BeBckXm3alElUV3IrIC1Vv4/edit?usp=sharing
Template: http://share.yellowrobot.xyz/1629812987-programming-tutorials/session_3.zip
Tasks:
Post delete function using HTML form, ControllerPosts and ControllerDatabase
Ability to save url_slug
and open URL using slug instead of post_id, for example http://localhost:8000/posts/my_post_title
Submit whole project as ZIP
Video: https://youtu.be/OSvtOrJ7bHw
Jamboard: https://jamboard.google.com/d/1S3oYruAJmrakj7fn0xbGQ_xJfI1u_pY289MjDQGCgNs/edit?usp=sharing
Template: http://share.yellowrobot.xyz/1629812987-programming-tutorials/session_4.zip
Tasks:
Implement so that after deletion and editing user is redirected to home page and sees message "post deleted" or "post updated"
Implement so that in home page you see list of all recorded posts (title and date of editing) and link to open editing form