How Wagtail CMS StreamFields are Saved in the Database (behind the scenes)

  Рет қаралды 7,552

Coding For Everybody

Coding For Everybody

Күн бұрын

Пікірлер: 14
@unperrier5998
@unperrier5998 4 жыл бұрын
Interesting, thanks. How does that work with searching? Normally you can specify which fields are searchable and which aren't. Doest that mean that if you search using say "type" or "value", you'll match all StreamFields even if none of the actual content fields contain any of those 2 words? It would be nice if it used a JSON column type (where available) but that's probably an ORM limitation. The standard way of implementing this would be to create multiple tables, one for each type of field (richtext, cta, cards...) and we'd have multiple rows (one for each field) and even a bridging table like we havein many-to-many relationships, but that means a whole lot more dB accesses, so the performance trade-off seems good to me: only one dB access then interpret some JSON and voilà. The only issue I see is that of searching.
@CodingForEverybody
@CodingForEverybody 4 жыл бұрын
This is a good point. And likely the reason that services like elastic search exist. If you used something like elastic you wouldnt have to worry about querying the JSONified streamfields. For the "Type" or "Value" query, it won't perform a fulltext search on the JSON as a string, it'll likely look through the JSON as a dictionary. An example would be: learnwagtail.com/search/?q=value - only 2 results (as of writing this). But every page on this site has a streamfield.
@unperrier5998
@unperrier5998 4 жыл бұрын
@@CodingForEverybody on a side note I wanted to use wagtail but moved to django-cms in the end because of streamfields: if you modify the model, the json can't be migrated. But with django-cms everything is sound relational. So that makemigrations will always apply the change.
@CodingForEverybody
@CodingForEverybody 4 жыл бұрын
@@unperrier5998 Sorry to hear that. Migrations with StreamFields are a bit tricky to navigate I completely agree with that. But at the end of the day it's just a text column with formatted json on it. You can write django data migrations to be applied before and after a migration file is run. To be honest, Ive almost never had to migrate streamfield data though - can I ask, what were you trying to do?
@unperrier5998
@unperrier5998 4 жыл бұрын
@@CodingForEverybody well during development you add and remove fields. to StreamFields, which makes the content in the dB is out of sync. Either you write some migration code like you said or you trash the dB. During the dev phase that's fine to restart from zero, but if I were to add a field in production I prefer to rely on tested migration automation (django, south) using a CMS like django-cms designed to natively support such migration rather than write some migration code. Also if it's really treated as a TEXT column then the only search available is textual and we lose the power of relational dB.
@unperrier5998
@unperrier5998 4 жыл бұрын
Another reason why I want to use django-cms (sorry for meandering, but I think you asked why) is because I want the non tech savvy editors to easily edit fields and I find django -cms awesome in that regard. Especially the personalisation: you can very easily set visitor or authenticated and then instantly view the content and more importantly edit it with a double click. And this can happen without any coding on my part :)
@23TrevorE
@23TrevorE 5 жыл бұрын
What a great video in a great series. That little bit more understanding of what's happening under the hood makes all the difference. Thank you for taking the time to educate us with these superb videos.
@CodingForEverybody
@CodingForEverybody 5 жыл бұрын
I'm happy to hear you're enjoying this series Trevor! Don't forget we have an awesome slack channel too at wagtail.io/slack - Kalob
@code-snippets
@code-snippets Жыл бұрын
This course is amazing 💯
@AntonZap
@AntonZap 2 жыл бұрын
thank you
@Lumpiness9149
@Lumpiness9149 3 жыл бұрын
Thank you for your work
@IllevensKO
@IllevensKO 4 жыл бұрын
it would've been extra helpful to mention how to access {{ blocks.first }} - for cases like displaying truncated richtext streamfield description of a post on a listing page. Adding a separate field on top of the streamfields would be confusing for admin.
@sakyaris2458
@sakyaris2458 5 жыл бұрын
Thank you very much! I think Wagtail has a huge potential.
@CodingForEverybody
@CodingForEverybody 5 жыл бұрын
I agree, HUGE potential! Big names like Google, Apple, NHS, Mozilla and NASA are already using it.
Creating a Call to Action StreamField in Wagtail CMS using a StructBlock
18:53
Coding For Everybody
Рет қаралды 10 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 197 М.
Ozoda - Lada (Official Music Video)
06:07
Ozoda
Рет қаралды 14 МЛН
Watermelon magic box! #shorts by Leisi Crazy
00:20
Leisi Crazy
Рет қаралды 23 МЛН
Wagtail: The Only CMS I Still Love After Years
49:34
CMS Philly, formerly Drupaldelphia
Рет қаралды 4,5 М.
7 Database Design Mistakes to Avoid (With Solutions)
11:29
Database Star
Рет қаралды 78 М.
How to use Orderables in Wagtail CMS
22:42
Coding For Everybody
Рет қаралды 14 М.
Postgres just got even faster
26:42
Hussein Nasser
Рет қаралды 30 М.
Registering Django Models with Wagtails ModelAdmin
12:17
Coding For Everybody
Рет қаралды 13 М.
How do indexes make databases read faster?
23:25
Arpit Bhayani
Рет қаралды 66 М.
Hashing Algorithms and Security - Computerphile
8:12
Computerphile
Рет қаралды 1,5 МЛН
How to Add a Basic StreamField to your Wagtail CMS Page
19:34
Coding For Everybody
Рет қаралды 26 М.
Ozoda - Lada (Official Music Video)
06:07
Ozoda
Рет қаралды 14 МЛН