question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prevent users from creating 'index' pages?

See original GitHub issue

Apologies if this has already been answered, but I couldn’t find any related issue.

While working through the Wagtail tutorial, we create a BlogIndexPage, and subsequently Blog posts. Once the Blog index is created, there is no need to create another BlogIndexPage. How can I restrict users from creating secondary index pages? E.g. is it possible to keep the BlogIndexPage from showing up as an option when creating a new page?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
sir-sigurdcommented, Oct 26, 2018

You could also try something like this

from django.utils.decorators import classproperty  # not sure if this is public API

class BlogIndexPage(Page):
    @classproperty
    def is_creatable(cls):
        return not cls.objects.exists()
1reaction
zerolabcommented, Oct 27, 2018

The ‘unofficial way’, as covered by tests is to override can_create_at and augment the parent check with a not cls.objects.exists()

https://github.com/wagtail/wagtail/blob/master/wagtail/tests/testapp/models.py#L862

Will work on adding max_count and updating the documentation to settle on one solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent users creating constraints or indexes with no name
The simplest way to do this (though it makes me shudder a bit) is to use a database level DDL trigger with EVENTDATA....
Read more >
How To Prevent Users From Creating Certain Page Types in ...
How To Prevent Users From Creating Certain Page Types in Wagtail CMS ; from wagtail.core.models import Page ; class BlogIndexPage(Page): ; = os....
Read more >
How to Prevent Google from Indexing Certain Web Pages
The most effective and easiest tool for preventing Google from indexing certain web pages is the “noindex” metatag. Basically, it's a directive ...
Read more >
Block Search Indexing with 'noindex' - Google Developers
A noindex tag can block Google from indexing a page so that it won't appear in Search results. Learn how to implement noindex...
Read more >
Prevent content from appearing in search results
Learn about the different methods you can use keep search engines from indexing specific content on your website.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found