I'm not much into commenting but thank you very much for this series, Kalob. This is undoubtedly the best learning source for Wagtail so far
A brilliant tutor, I just couldn't wait until end of the lesson to make this comment.
In wagtail 2.6.1 it is required to specify a name for a streamfield block.
('title_and_text', blocks.TitleAndTextBlock(classname='text_and_title')
or you will get the exception:
env/lib/python3.7/site-packages/wagtail/core/blocks/stream_block.py", line 44, in __init__
block.set_name(name)
TypeError: set_name() missing 1 required positional argument: 'name'
Brother, you are amazing. I have learned a lot and incredibly fast, you have an innate talent for teaching. And I am also following the videos with a low level of English, only with the automatic translation of the UA-cam subtitles.
Greetings from Chile!
This is awesome! Thanks for your time and energy
Why are you creating a new app for each page? Wouldn't it be better to just add it to the original models.py and create a new html template? Just getting started with the series so there is probably a good reason. But so far there are now 3 apps created.
In these videos, practice. And to also split out larger chunks of logic, should we need to. Separating the apps now is easier than having to do it in the future and writing a data migration.
Though I've seen pages all living under one models.py file and there was nothing wrong with that.
@@CodingForEverybody ok thanks for the reply. That makes sense. My previous Django project has a singular models and used views, so wagtail is a bit different. Thanks for these tutorials they have really helped.
Not sure what I'm doing wrong, but my StreamField shows :
title
Name of title
text
Text I put in.
Is that just because it's development mode, or am I doing something incorrect? I tore the whole project down and started over, and still got this output.
I'd need to see more of your code. You can put it up in a GitHub Gist. But generally you need to:
1) Add the StreamField field (ie. blocks.CharField) to your StreamField, and
2) Add the new field to your template (ie. {{ self.new_field_name }}
@@CodingForEverybody the reason none of this is working for me, is at this step templates are not even being looked for. After putting the info for streams/blocks.py and trying to refresh "About" the page refreshes without the template error. So it seems its not even trying to access templates any more. Everything in flex_page.html and home_page.html, seems to go through the template, though.
@@marquesjohnson870 If there's no template error, it means it's found the template. Your loop looked like it was working.
But this thread is getting a bit long to provide support on UA-cam. Have you joined the Slack community yet? wagtail-slack.now.sh/ We can help you out a lot more in there!
@@CodingForEverybody I have joined there. But it couldn't have found the template because I hadn't made one yet.
@@marquesjohnson870 If you have DEBUG = True in your settings, and you're using a StreamField on a page and you're requesting a template that doesn't exist, you'll get a Template Does Not Exist error.
First step is to get ANY streamfield template to render. It doesn't need dynamic content, it just needs SOMETHING to show up.
I'm looking forward to seeing you in the Slack community!
I keep getting this error on creating a StreamField, the block has 2 simple CharBlocks, please help?
ERROR: AttributeError: 'list' object has no attribute 'get_prep_value'
Can you put your StreamField into a gist (gist.github.com/) and share the URL with me? And maybe also include your page class that's trying to use this streamfield.
My first thought is that you might be using a ListBlock. Or the `content = StreamField(...)` property is misconfigured.
@@ruchitmicro8409 deleting all migrations and dropping the table helped for me. Just makemigrations again
I got it solved this is what I did,
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
paste the above two code in a terminal targeting your project directory (It will remove your migrations).
Then, remove db.sqlite3 from your project directory.
Then makemigrations and migrate
My mistake was I didn't watch the entire video where Kalob skipped giving default value when asked during the migration and I gave the default value. Hence my code got fucked up
Hi Thanks for the great course, I have a blog which users can add articles and I want user to have the ability to make collection or group and add their articles to it (something like youtube where you can add videos to playlist) .. what is the best way to do it with wagtail ?
Good question! There are LOTS of ways to do this. The simplest method would be to create another page (ie. ArticleCollectionPage) and use an Orderable to select blog pages.
You could also use a StreamField as well but imo that's not using StreamFields for its intended use (that's not official, just my opinion). But a StreamField would work!
@@CodingForEverybody thanks for your replay, I love you man :D
okay, your suggestion is great if I want to make users add articles to his collection from (ArticleCollectionPage) .. but what if I want to give him the ability also to choose the collection in the article page (ArticlePage), something like when you create article and choose category or tags.
how to make this ?
and thanks again you are a life saver.
@@votelearn1244 Same way, its just one more layer of recursive code.
You could create a Clusterable Model with an Orderable, register the Clusterable Model with the model admin and register as a snippet, and then use a SnippetChooserPanel.
You'll see an example of this in the Menus app github.com/CodingForEverybody/learn-wagtail/blob/master/menus/models.py#L17-L80
Everything works but I keep getting this:
--module streams
--unresolved import 'streams'
Server still runs but the error annoying. How can I remove it.
Btw, great video tutorials. I can see big potential for Wagtail.
"streams" isnt a module in your code. You just ned to remove the line that starts with `from streams import ....`
It seems django-debug-toolbar is causing some weird bug in the latest release of Wagtail "index error out of range" something, when I try to edit a page in the admin area. Disabling it fixes the problem. :P
So I've heard. Very strange. I havent upgraded to Wagtail 2.5 with Debug Toolbar yet. When I do, and if I can find a solution, I'll make a video about it!
I'm getting the same error "list index out of range" when I try to edit the about page in the admin panel. @@CodingForEverybody Is there a way to downgrade Wagtail from 2.5 or remove the DDT?
Of course there is. I'd suggest removing DDT instead of downgrading Wagtail though.
To remove DDT you can remove the DDT lines from your middleware and installed apps in dev.py. And to remove it entirely you can use `pip uninstall django-debug-toolbar`
And if you really wanted to downgrade Wagtail, you could use `pip install wagtail==2.4`
If you're on Wagtail 2.5 right now, make sure you upgrade to 2.5.1 as there was a bug that was fixed. `pip install wagtail --upgrade` or `pip install wagtail==2.5.1`
server gives me an error "no module named streamswagtail"
Make sure you're adding "streamswagtail" to your base.py file (in the INSTALLED_APPS) and make sure your directory is called "streamswagtail". In this video and the the source code I'm using a module called "streams", the name is slightly different but very important.
I forgot the comma after the app (streams)
Thank you very much
@@CodingForEverybody
I have same problem, but my base.py is correct. (Django==3.0.6, python==3.8, wagtail==2.9)
@@alexmangir Me too - did you solve this issue? I can't find much online about it
For more videos like this, check out learnwagtail.com and the entire UA-cam playlist at wagtail.io/course