Skip to content
This repository

404 Error for new pages placed under "Blog" #561

Closed
ezheidtmann opened this Issue February 11, 2013 · 11 comments

3 participants

Evan Heidtmann Stephen McDonald Aleksandr Vladimirskiy
Evan Heidtmann

Today I installed a new instance of mezzanine by the standard method. No customizations yet.

In the backend, I added a new page and dragged it to it is listed below the default "blog" item, next to Team and History. But when I try to visit the page, I get the error "No BlogPost matches the given query."

The request url is "http://localhost:7000/blog/mypage".

If I move the page to a different part of the menu (even top-level), its URL does not change and so the error persists.

Any advice or a pointer to implementing a fix would be much appreciated. I'm new to mezzanine, but hopefully not for long. :-)

Stephen McDonald
Owner

I'm gonna leave this issue open since the experience of this situation could definitely be improved.

As for what you want to do, the page would need to have a slug that doesn't match the blog app's urlpatterns - more specifically, there's no simple way for Django to distinguish between a page called "mypage" and a blog post titled "mypage". You'll see the team and history demo pages have slugs that don't start with "/blog/".

Stephen McDonald
Owner

Just to be clear, when I say slug I'm referring to the URLs.

Evan Heidtmann

Thanks for getting back to me. That makes sense; everything under "blog/" should be blog entries, not pages.

However, the URL field is not present on the admin UI for pages which are positioned under "Blog". It remains absent even after moving the page to another position in the menu. (Earlier, I had thought the URL field was missing entirely! But it IS present for new pages posted at the top level)

Stephen McDonald
Owner

It's hidden since it now thinks that the page is related to a specific feature in the blog app - again this experience could really be improved. For now you'll need to either delete the page and create it again, or change its slug manually (via the Django shell etc).

Evan Heidtmann

OK, got it. I edited the DB manually to rescue my pages, but my content editors won't do that. Any hints on how to improve the experience? I might have a little while to work on it.

Stephen McDonald
Owner

It really needs more thought and discussion, it might be useful to post this thread to the mailing list to try and gather some ideas.

A very rough initial idea I have is to try and intercept 404 responses for non-page views via middleware (there's a PageMiddleware this could occur in) and then allow the middleware to check for a valid page, and use the page view to return a normal page response.

Aleksandr Vladimirskiy

Hi guys,

I put together what I think could be a solution and a couple of simple tests. Hope this helps.

ButchershopCreative@1581285

Sasha

Stephen McDonald
Owner

Thanks (Aleksandr/Sasha?)

It's a nice fix, but I think it would be better to solve this in a more generic way that isn't specific to the blog app.

Aleksandr Vladimirskiy

Would love to help to do that.

My understanding is that the Blog app is unique in that it overrides page functionality specifically, hence the specific solution.

What it the generic issue that would have to be solved? Are we expecting other possible apps that would override Page functionality the same way Blog does, with it's own BLOG_SLUG setting? Or is there some other generic case?

Stephen McDonald
Owner

Yes you're right it is unique like that, but the idea of linking pages into regular Django apps is one of the main features of Mezzanine - the blog is just the canonical example of it.

http://mezzanine.jupo.org/docs/content-architecture.html#third-party-app-integration

Aleksandr Vladimirskiy

Of course, I understand the limitation of my solution. I will read a bit more of the source to see if I can see a more generic approach.

Stephen McDonald stephenmcd closed this issue from a commit April 09, 2013
Stephen McDonald Add special handling in PageMiddleware for non-page views that raise …
…404s, but do so with a valid page slug - in this case, we use the page view instead, which allows pages to be created that may match non-page urlpatterns. Closes #561.
840e776
Stephen McDonald stephenmcd closed this in 840e776 April 09, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.