codingforeverybody / learn-wagtail Goto Github PK
View Code? Open in Web Editor NEWThe repo that goes hand in hand with the Learn Wagtail CMS Video Course (https://learnwagtail.com/tutorials/)
Home Page: https://learnwagtail.com/
The repo that goes hand in hand with the Learn Wagtail CMS Video Course (https://learnwagtail.com/tutorials/)
Home Page: https://learnwagtail.com/
After the course on (Snippets + Orderables) and going through the doc. I don't see a way to have default value selected on the admin form for an InlinePanel('my_orderable_related_name')
How would you go about consuming an API in Wagtail? e.g a recipe api to enable you to embed recipes to blog posts from the admin dashboard?
On this tutorial How to Create a Custom Wagtail Menu System
Using {% get_menu "main" as navigation %}
without an existing menu in the admin throws an error
What's a workaround?
Environment:
Request Method: GET
Request URL: http://localhost:8000/blog/
Django Version: 2.2.4
Python Version: 3.7.4
Installed Applications:
['home',
'search',
'flex',
'streams',
'blog',
'menus',
'site_settings',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.contrib.settings',
'wagtail.contrib.routable_page',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware']
Template error:
In template C:\Users\Rory.Ferguson\Repositories\Bitbucket\joudev\joudev\home\templates\home\main_menu.html, error at line 19
Menu matching query does not exist.
9 : <a class="navbar-brand" href="/"><img src="{{ logo.url }}" alt="" class="center ml-3 mr-5" style="width: 100px;height:auto;" /></a>
10 : {% endif %}
11 :
12 : <!-- BURGER MOBILE MENU -->
13 : <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
14 : <span class="navbar-toggler-icon"></span>
15 : </button>
16 :
17 : <div class="collapse navbar-collapse" id="navbarColor01">
18 :
19 : {% get_menu "main" as navigation %}
20 :
21 : {% if navigation.menu_items %}
22 : <ul class="navbar-nav mr-auto">
23 : {% for item in navigation.menu_items.all %}
24 : <li class="nav-item">
25 : <a class="nav-link" href="{{ item.link }}">{{ item.title }}</a>
26 : </li>
27 : {% endfor %}
28 : </ul>
29 : {% endif %}
Traceback:
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\core\handlers\base.py" in _get_response
145. response = self.process_exception_by_middleware(e, request)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\core\handlers\base.py" in _get_response
143. response = response.render()
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\response.py" in render
106. self.content = self.rendered_content
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\response.py" in rendered_content
83. content = template.render(context, self._request)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\backends\django.py" in render
61. return self.template.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render
171. return self._render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\test\utils.py" in instrumented_test_render
96. return self.nodelist.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\loader_tags.py" in render
150. return compiled_parent._render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\test\utils.py" in instrumented_test_render
96. return self.nodelist.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\loader_tags.py" in render
188. return template.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render
173. return self._render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\test\utils.py" in instrumented_test_render
96. return self.nodelist.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render
937. bit = node.render_annotated(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\base.py" in render_annotated
904. return self.render(context)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\template\library.py" in render
192. output = self.func(*resolved_args, **resolved_kwargs)
File "C:\Users\Rory.Ferguson\Repositories\Bitbucket\joudev\joudev\menus\templatetags\menus_tags.py" in get_menu
9. return Menu.objects.get(slug=slug)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\db\models\manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Rory.Ferguson\.virtualenvs\joudev-4JJUEelb\lib\site-packages\django\db\models\query.py" in get
408. self.model._meta.object_name
Exception Type: DoesNotExist at /blog/
Exception Value: Menu matching query does not exist.
Hi and thanks for the videos. Any plan to add multi language support?
I have tried to expose author name in API. But it's not exposing.
Here what is I am getting in API view.
"blog_authors": [
{
"id": 1,
"meta": {
"type": "blog.BlogAuthorsOrderable"
}
},
{
"id": 2,
"meta": {
"type": "blog.BlogAuthorsOrderable"
}
}
],
Here is my models.py
class BlogAuthorsOrderable(Orderable):
"""This allows us to select one or more blog authors from Snippets."""
page = ParentalKey("blog.AddStory", related_name="blog_authors")
author = models.ForeignKey(
"blog.BlogAuthor",
on_delete=models.CASCADE,
)
panels = [
# Use a SnippetChooserPanel because blog.BlogAuthor is registered as a snippet
SnippetChooserPanel("author"),
]
@register_snippet
class BlogAuthor(models.Model):
"""Blog author for snippets."""
name = models.CharField(max_length=100)
website = models.URLField(blank=True, null=True)
image = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.SET_NULL,
null=True,
blank=False,
related_name="+",
)
panels = [
MultiFieldPanel(
[
FieldPanel("name"),
# Use an ImageChooserPanel because wagtailimages.Image (image property)
# is a ForeignKey to an Image
ImageChooserPanel("image"),
],
heading="Name and Image",
),
MultiFieldPanel(
[
FieldPanel("website"),
],
heading="Links"
)
]
def __str__(self):
"""String repr of this class."""
return self.name
class Meta: # noqa
verbose_name = "Blog Author"
verbose_name_plural = "Blog Authors"
Here is AddStory
Class
content_panels = Page.content_panels + [
FieldPanel("alternative_title"),
FieldPanel("excerpt"),
ImageChooserPanel("blog_image"),
StreamFieldPanel("content"),
FieldPanel('tags'),
MultiFieldPanel(
[
FieldPanel("categories", widget=forms.CheckboxSelectMultiple),
],
heading="Categories"
),
MultiFieldPanel(
[
InlinePanel("blog_authors", label="Author", min_num=1, max_num=4)
],
heading="Author(s)"
),
]
api_fields = [
# Exposed the related_name from the BlogAuthorsOrderable
APIField("blog_authors"),
]
Hello,
I've watched the interesting Wagtail CMS: How to Create a Custom Wagtail Menu System lesson and I'd like to ask you if you can suggest the right and/or easy way to implement a second level menu in order to display drop-downs.
I'd like to take this opportunity to congratulate you for the great tutorial you've done.
Regards
Alfredo
Hello and thank you for you tutorial. I've noticed that the tag view it's not working. Should we have to implement it, following the route of the category view? Thank You.
Hi ,
everthing is ok with the caroussel in the backend but not showing at all in the home page
Thx for help
wagtail 5.0.2
Django 4.2.3
python 3.9
I tried to copy the code for models.py for contact app. But I got the ModuleNotFoundError as follow:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/core/management/init.py", line 394, in execute
autoreload.check_errors(django.setup)()
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "xxxxxxxxxxx/venv/lib/python3.9/site-packages/django/apps/config.py", line 193, in create
import_module(entry)
File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 972, in _find_and_load_unlocked
File "", line 228, in _call_with_frames_removed
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 972, in _find_and_load_unlocked
File "", line 228, in _call_with_frames_removed
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'contactwagtail'
Any help please?
Hello,
There is a typo in the code example on this page :
https://learnwagtail.com/tutorials/restricting-parent-and-child-pages/
parent_page_type instead of parent_page_types
Regards
This code and the corresponding article list outdated endpoints and library names
Hi Kalob,
Really great content. Thank you.
Just found a little typo, which didn't allow me to submit the contact form. The ugly version, which you were showing in the video was fine. But after adding style, you somehow changed the input tag to button tag, but changed the type from "submit" to "button".
<button type="button" class="btn btn-success">
Submit Form
</button>
<button type="submit" class="btn btn-success">
Submit Form
</button>
In the code snippet section the parent_page_type
class variable should be in plural form parent_page_types
otherwise it won't have any effect.
Link: https://learnwagtail.com/tutorials/restricting-parent-and-child-pages/
Great video about updating the admin panel. Thank you!
This issue is regarding:
learn-wagtail/core/wagtail_hooks.py
If you're using Django 3, you can replace
from django.contrib.staticfiles.templatetags.staticfiles import static
with
from django.templatetags.static import static
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.