Choose django-cms start page

django-cms always uses the topmost page as the start / destination page. Now I want to have a navigation that looks like this foo-home-bar and home for the landing page.

One way is to add a dummy page to /, which redirects to / home, but for me it is a bit rude. Is there a better solution? I am not against changing the cms code itself.

+6
source share
3 answers

The easiest way, instead of creating a page that redirects, is to simply use the generic django redirect view.

set it to the top level urls.py

url(r'^$', RedirectView.as_view(url='/home/')), 

and of course add import from django.views.generic.base import RedirectView at the beginning and everything should be installed.

( '^$' only picks up the root URL and RedirectView redirects wherever you want. I was a little unsure of using it myself, but I saw how many large websites do redirects when you go to their site ..)

+3
source

The first page you create seems to be the home page, just add other root pages as needed and enable navigation on them. This is what I did.

Our first page was a test, and then a few child pages. on the administration page, you can click and drag the pages to change the child / parent order. we rename the test to the home page and translate the child pages to another root page.

You can also override the default menu by creating a template in the /menu.html menu. There you can override the order by adding if statements to some. You can also write it in your base.html, having a menu: <ul id=menu> <li><a href="/foo/>foo></a></li> <li><a href="/">Home</a></li> {% show_menu %} <ul>

And you just have a bar and other pages that you wanted in navigation, but not foo or home.

There is an icon on the homepage on which other pages will be displayed, indicating the root page that I assume.

+1
source

The page with the lowest tree_id in the cms_page table is the home page. This is usually the first page you have created. If you want to create another page on your home page, you can manually change the tree_id values ​​in your database (but, unfortunately, without using an administrator.)

0
source

Source: https://habr.com/ru/post/916692/


All Articles