8000 Suggestion: Add optional validation to prevent future dates in DateFields used in blog-like pages · Issue #13113 · wagtail/wagtail · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Suggestion: Add optional validation to prevent future dates in DateFields used in blog-like pages #13113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Yanmatheus0812 opened this issue May 14, 2025 · 1 comment

Comments

@Yanmatheus0812
Copy link

Is your proposal related to a problem?

Yes. During user testing, I found that when creating a custom page type such as BlogPage with a models.DateField, Wagtail allows the user to input and publish a page with a date in the future (e.g., 2026-10-08). While this is technically allowed by Django, it may lead to unintended behavior in CMS contexts, where a future publication date usually implies scheduled publishing — or at least requires extra editorial attention.

This can be misleading to editors or content creators, especially if the date is displayed on the site and suggests content that hasn't been written yet. In my test scenario, the page was published immediately even though the date was far in the future.

Describe the solution you'd like

An optional validation mechanism or configuration to restrict future dates in DateFields could be helpful — especially for common use cases like blogs, news articles, and events. Ideally, this could be implemented as:

  • A default validation toggle (allow_future_dates=False) at the field or page level.
  • Or a documentation example on how to restrict future dates using clean() or Panel hooks.

This way, developers and content managers can choose whether future dates are valid for their use case.

Describe alternatives you've considered

  • Adding custom validation to the clean() method of the model (which works but requires extra effort for each developer).
  • Using the Wagtail scheduling system, which is separate from the page content’s date field.
  • Accepting this as intended behavior, although it can confuse users and result in content showing with inaccurate dates.

Additional context

This was discovered as part of my manual test case (creating a blog post with a future date) in a Wagtail 5.2.1 + Django 5.2 environment. The result was that the page published normally, despite the future date. In my test plan, this was marked as a failed case because the behavior did not match editorial expectations.

It might help if future dates were either flagged or required to be handled differently (e.g., scheduled publishing).

Working on this

I'm not planning to work on this feature myself, but I'm happy to test any proposed solutions or contribute feedback during development.

@gasman
Copy link
Contributor
gasman commented May 14, 2025

Thanks for the suggestion @Yanmatheus0812!

This should be possible through a Django validator, or a custom form with a clean method. Definitely in favour of better documentation for this, and maybe having Wagtail provide a standard 'future date' / 'past date' validator - I guess this would be a wrapper around Django's MaxValueValidator / MinValueValidator with a callable to return today's date. (It's a little surprising that Django doesn't provide this as a built-in...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0