diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 68a21731b8..ce6d2566f8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,8 +1,15 @@ Changelog ========= +0.4 (xx.xx.20xx) +~~~~~~~~~~~~~~~~~~ * When logged in user visits login page, they are now redirected to the dashboard - * Fix: Deleting an item from an InlinePanel, then generating a validation error on saving, no longer causes the deleted item to confusingly reappear with an error of it's own. + +0.3.1 (xx.xx.20xx) +~~~~~~~~~~~~~~~~~~ + * Fix: When constructing dummy requests for pages with no routable URL, fall back on a hostname from ALLOWED_HOSTS and finally 'localhost', to avoid 'Invalid HTTP_HOST header' errors on preview when DEBUG=False. + * Fix: Ensure that url_path is populated when previewing a newly created page, to avoid unnecessarily taking the above fallback. + * Fix: Deleting an item from an InlinePanel, then generating a validation error on saving, no longer causes the deleted item to confusingly reappear with an error of its own. 0.3 (28.05.2014) ~~~~~~~~~~~~~~~~ diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index 809497d83e..9bf6dbf444 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -349,6 +349,10 @@ def preview_on_create(request, content_type_app_name, content_type_model_name, p if form.is_valid(): form.save(commit=False) + # ensure that our unsaved page instance has a suitable url set + parent_page = get_object_or_404(Page, id=parent_page_id).specific + page.set_url_path(parent_page) + # This view will generally be invoked as an AJAX request; as such, in the case of # an error Django will return a plaintext response. This isn't what we want, since # we will be writing the response back to an HTML page regardless of success or diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index f72e6f6f9e..30ffc8a77f 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -581,7 +581,12 @@ class Page(MP_Node, ClusterableModel, Indexed): path = url_info.path port = url_info.port or 80 else: - hostname = 'example.com' + # Cannot determine a URL to this page - cobble one together based on + # whatever we find in ALLOWED_HOSTS + try: + hostname = settings.ALLOWED_HOSTS[0] + except IndexError: + hostname = 'localhost' path = '/' port = 80