How do you view a published django-cms page using a path that incorporates the slug?
I installed django-cms without error, and I can view the default cms homepage just fine. I created and published a simple "About" page with the slug "about", but when I visit http://localhost:8000/about/ I get a 404 error. I can see the page if I use the "View on site" button, but that takes me to http://localhost:8000/?preview=1&language=en, not the real published path.
What am I doing wrong?
you won't get access until you check the published in cms page list view in admin.
View on site help with a preview before page is published.
After digging through the code, I discovered that django-cms doesn't actually expose pages via their slug unless they're created UNDER a home page. The code that looks up a page via their slug looks in the cms_title table, and it stores '' for the slug for any page that's not a child. Very unintuitive, but after I re-created the page under a "Home" page, I could then access it via the /about/ page.
Related
My problem is the following: i have a simple web app that requires a user to upload a file, submitting a POST request to the flask server.
If the file does not match the the requirements set by the application, the user is redirected to the same html page containing a form, and a message warning the user of their mistake is flashed onto the html page.
My problem is the following: currently the form is located at the bottom of the html page, but when the user tries uploading an unsuitable picture, they are redirected to the beginning of the page.
How do I tell flask to redirect the user to a specific section of the page (ie the section where the form is located in?)
you can try use id in your html simply add an id to the form then in your url add an #myFormId, if you'r using url_for do this
redirect(url_for("index")+"#myFormId")
also check this too.
Users can submit links to external sites via a form and "Event Website" field on my site. The site is sent to the "link" model in the admin and is rendered in the template with {{ item.title }} .
However, not all links are loading the external site.
When on the production site, only links with "https://" included that are actually secure navigate to the external site.
Links entered without "https://" that are not secure such as "http://www.notsecuresite.com", "notsecuresite.com" or "www.notsecuresite.com" do not load. I get "This site can't be reached" and my site adds "https://http//" to the link when clicking on it and attempting to load it.
How can I get my page to load the external site no matter how the link is entered (given that it's valid)?
I'm attempting to set a page as the root home page of my wagtail based site.
I know you can set the homepage using the sites setting. But, my use case is different.
I'm using a "redirect" page which redirects to an index page as the homepage. The index is restricted to only allow ertain page types (since it's an index....). But, this causes issues with other pages not being in the tree if it was set at the root.
Hence, the redirect. But, upon redirecting the serve view of the redirect page to use this page it picks up the slug.
I still want it to appear at the root url. Meaning, /. How can I achieve this?
High level description:
from django.shortcuts import redirect
class IndexPage(Page):
# children restricted to IndexSubpage
class IndexSubpage(Page):
# parent restricted to IndexPage
class RedirectPage(Page):
def serve(request):
# Link is a link to a page through a ForeignKey....
return redirect(self.link, permanent=True)
So, this will pick up the slug of IndexPage instead of being at /
I am making a personal site. I have a blog page(site.com/blog), where I have a list of my blog posts. If I want to check a blog post simple enough I can click it and the code:
<h1>{{ obj.topic_title }}</h1>
will get me there. Also if I want to go to my contacts page (site.com/contacts). Easy enough I click nav contacs button and I go there
Contacts
but if I enter a blog post (site.com/blog/1), I am using the same template and if I want to go to my contacts page I have to yet again click the
Contacts
link, but that will port me to a 404 page site.com/blog/contacts . How do I deal with this problem without harcoding every single page
Use the built-in Django url template tag, which takes the view name and returns an absolute path to it.
Returns an absolute path reference (a URL without the domain name) matching a given view and optional parameters.
You can give it a view name and any of its view parameters as well. This is much better than how you link to the blog page:
{% url 'blog-view-name' obj.id %}
This ensures that if you ever change the structure of your views, it will still not break your links.
How do you point blogs to a menu item in Mezzanine? I am able to point my blogs to Home using urls.py but how about to page types like link and richtextpage?
Add a rich text page, call it Blog or however you want, then in meta data group, in the field URL add /blog/ or whichever is the url to the main blog app. Mezzanine will match the url with the page and will add the Page object to the rendering context, so you can use it in templates.