Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose the start page django-cms

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.

like image 744
Basil Avatar asked May 25 '12 17:05

Basil


People also ask

How to create a website with django CMS?

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 Django?

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.

How much does Django cost?

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.

How to create a demo project in Django?

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.


2 Answers

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...)

like image 149
Thomas Remmert Avatar answered Oct 04 '22 10:10

Thomas Remmert


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.

like image 24
Azerith Avatar answered Oct 04 '22 11:10

Azerith