Python Flask Tutorial #5: SQLAlchemy ManyToMany relationship | Flask crash course for beginners

preview_player
Показать описание
In this #5 video of the Python Flask Tutorial for absolute beginners we will create the second model with SQLAlchemy ORM - the Tag, and we'll know how to use migrations. Then we'll create a brand new, additional table to store data about ManyToMany relationship, and set up the SQLAlchemy ManyToMany relationship between Post and Tag models

Follow me @:

============ SOURCE CODE ================
📎️ The SOURCE CODE is available via Patreon:
======================================

✴️✴️✴️ This Flask tutorial ✴️✴️✴️

Python Flask Tutorial #0: the Demo of the blog build with Flask

Python Flask Tutorial #1: Installing and Basic Flask App

Python Flask Tutorial #2: Jinja Template Inheritance

Python Flask Tutorial #3: Flask Blueprints

Python Flask Tutorial #4: Using SQLAlchemy to create models

Python Flask Tutorial #5: SQLAlchemy ManyToMany relationship

Python Flask Tutorial #6: Basic Search and HTML forms

Python Flask Tutorial #7: Adding Pagination

Python Flask Tutorial #8: Update records in database with Forms

Python Flask Tutorial #9: Flask Admin panel

Python Flask Tutorial #10: Restrict access to admin panel

Python Flask Tutorial #11: Custom 404 error page

Python Flask Tutorial #12: Using of Custom CSS styles

✴️✴️✴️ Web Scraping course ✴️✴️✴️
is available via Patreon here:

or its landing:

As an example for this Flask Crash Course I use a blog engine.

✴️✴️✴️ PLAYLISTS ✴️✴️✴️

🔹Django 3 Tutorial: Blog Engine

🔹Kivy Tutorial: Coppa Project

🔹Telegram Bot with Python (CoinMarketCap)

🔹Python Web Scraping
Рекомендации по теме
Комментарии
Автор

What video should I make next? Any suggestions? *Write me in comments!*
Follow me @:

Help the channel grow! Please Like the video, Comment, SHARE & Subscribe!

RedEyedCoderClub
Автор

This migrates commands things not working in the newer version. Can you please update the course? This will be very helpful.

gyanaranjannayak
Автор

Great tutorial, very informative. Gracias

dannisisgt
Автор

Wow! This tutorial answers my question but in a case where by the relationship table has addition fields aside those ones from the tables in questions? How do we go about doing that insertion to the helper table? Thanks for your prompt to this question too.

SPaICTHub
Автор

У Мигеля в его мегатуториале тоже приводится пример связи многие ко многим, но у него ужасно неудачный -фолловед, фолловер, фолловерс. мало того и так фиг поймешь так еще и добавляет путанице сам пример. у вас все гораздо понятнее - посты и теги. мы создали таблицу ассоциаций - тут все ок. но когда мы в модели Post добавляем поле tags как алхимия понимает по какому полю надо связывать посты и теги? Мигель прописывает primaryjoin и secondaryjoin. Но тут работает и без этого. Я застрял. эни хелп? куда хотя бы смотреть

avbolshakov
Автор

and if you want the tags to be UNIQUE,
for example its name, Tag(name='flask') and you want to add a tag that is already in the table, wouldn't it raise an exception?

kyo
Автор

Its so much simpler to do this with Django

CharleswoodSpudzyofficial
Автор

The MigrateCommand does not work anymore what to do?

abhilashajayaswal
Автор

Hi, I have a question. I know that if I wanted to get all elements of the Tag table in my views.py file, I'd do models.Tag.query.all(). What would be the equivalent for the posts_tags table? I need to display its contents but I can't find a way to do it. Thanks in advance!

bellarketrash
Автор

Flask-Script is not supported anymore.

sarkaran