The django-cms always uses the top-most page as the start/landing page. I now want to have a navigation that looks like this foo-home-bar and home to be the landing page.
One way would be to add a dummy page at / that redirects to /home, but this seems a bit crude to me. Is there any better solution? I don't mind changing the code of the cms itself.
Open the terminal application on your computer and go to a safe folder (i.e. cd ~/Projects ), then: Open your browser and insert http://localhost:8000/; there you should be invited to login and continue with Step 3: create your first page. By the way, django CMS has no license costs!
What is the best way to set a main page in a Django website? thanks! Show activity on this post. The new preferred way of doing this would be to use the TemplateView class. See this SO answer if you would like to move from direct_to_template.
django CMS is free! django CMS is a content management system used by thousands of website owners, developers, businesses and content editors. Without the support of our sponsors, partners and users like you, django CMS would not be possible. django CMS is open source and supported by the community of contributors.
Info: The demo project is a minimal django project with some additional requirements in the requirements.txt. Open the terminal application on your computer and go to a safe folder (i.e. cd ~/Projects ), then: Open your browser and insert http://localhost:8000/; there you should be invited to login and continue with Step 3: create your first page.
The easiest way, instead of creating a page that redirect is to just use django's redirect generic view.
set it in your top level urls.py
url(r'^$', RedirectView.as_view(url='/home/')),
and of course add the from django.views.generic.base import RedirectView
import at the beginning and you should be all set.
('^$'
only catches the root url and the RedirectView redirect wherever you want. I was a bit unsure about using it myself, but I saw a lot of major websites doing a redirect when you get on to their site...)
The first page you make seems to be the home page, simply add other root pages as needed and enable navigation on them. This is what i have done.
Our first page was test, and then some child pages. in the admin page you can click and drag the pages around to change the child/parent order. we renames test to home and shifted the child pages to another root page.
You can also override the default menu by make a template in menu/menu.html
In there you could override the order by adding in some if statements.
You could also hardcode it in your base.html having the menu something like:
<ul id=menu>
<li><a href="/foo/>foo></a></li>
<li><a href="/">Home</a></li>
{% show_menu %}
<ul>
And just have bar and the other pages you wanted in the navigation but not foo or home.
The homepage has an icon on it that the other pages wont, denoting the root page I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With