0

I am thinking along the lines of /mysite/blogs/new. I know about add_child and about Routablepage, also the 'permissions route' but I still don't see how to permit page creation via a URL.

I am surprised that there do not appear to be any instructions for doing this, as relying on the admin method surely isn't acceptable for many 'naive' users. Indeed, it took me a while to realise that Wagtail isn't like Wordpress, in the sense of having an 'Add Post' button or the like.

The documentation does not clearly state that users are (apparently) expected to create pages via the Admin section either. In fact, there seems to be an assumption that developers will be familiar with Django, even though a CMS ought to be easier to use IMO.

Just to be clear, I think that Wagtail is great but the instructions leave something to be desired. Perhaps I will attempt to update them myself!

  • Wagtail fundamentally does not try to be Wordpress. Where Wordpress provides a single fixed page model (title, body, tags...) Wagtail expects you as a developer to define page models and templates yourself. On that basis it makes sense for Wagtail to keep a clear distinction between the site frontend (which you build) and the admin (which is provided for you) - Wordpress can get away with blurring those lines because both halves are provided for you. You _can_ work around Wagtail's intended workflow, but that's the point where you will have to drop down into Django development. – gasman Jun 08 '17 at 08:56

1 Answers1

1

If you have the Edit Bird/Userbar enabled, then it presents a button to add a child page at any point in the page tree so long as you have permission to add one there. If you wish to give naïve users this option then you could make their permissions fairly restrictive, so that they only see this option at certain locations, and they don't see any of the other 'settings' areas of the Admin.

Wagtail Userbar

The admin page for adding this does have its own URL: it typically looks like http://www.example.com/admin/pages/13/add_subpage/, where 13 is the ID of the current page. If instead you want to present that link yourself, you can manually add the link in the template as

<a href="{% url 'wagtailadmin_pages:add_subpage' page.id %}">Add a child page</a>

but first you should ensure that the user has the relevant permission. This is best done in Python, rather than in the template. See https://github.com/wagtail/wagtail/blob/master/wagtail/wagtailadmin/userbar.py for how Wagtail does this.

To get closer to your original request, you could combine all the above with RoutablePageMixin, by creating a route 'add' which redirects to the same URL:

@route(r'^add$')
def add_child_page(self, request):
    return redirect(reverse('wagtailadmin_pages:add_subpage', args=[self.pk]))
nimasmi
  • 3,978
  • 1
  • 25
  • 41
  • I didn't even know about the "Edit Bird/Userbar"! I had implemented the RoutablePageMixin but I wasn't quite sure how to use it, so your example is very useful - thank you. – Richard Prosser Jun 09 '17 at 10:50