Catch the exception if the visit count rule doesn't have a page
This commit is contained in:
@ -6,6 +6,7 @@ from importlib import import_module
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.contrib.sessions.models import Session
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
@ -239,6 +240,12 @@ class VisitCountRule(AbstractBaseRule):
|
||||
from wagtail_personalisation.adapters import (
|
||||
get_segment_adapter, SessionSegmentsAdapter, SEGMENT_ADAPTER_CLASS)
|
||||
|
||||
# Django formsets don't honour 'required' fields so check rule is valid
|
||||
try:
|
||||
self.counted_page
|
||||
except ObjectDoesNotExist:
|
||||
return False
|
||||
|
||||
if user:
|
||||
# Create a fake request so we can use the adapter
|
||||
request = RequestFactory().get('/')
|
||||
|
Reference in New Issue
Block a user