Search code examples
pythonhtmldjangopython-3.xdjango-oscar

How to add new created page url to modified django-oscar


I'm a beginner in django-oscar and I try to manage a new view on the page.

I've already created two pages with django-oscar dashboard,

https://ibb.co/cM9r0v

and made new buttons in the templates:

Lib/site-packages/oscar/templates/oscar/partials/nav_primary.html

https://gist.github.com/Kalinar/076fc8144869c3b50fc0bc9e52f825e4

I have no idea how to make a good a href="???" to new pages in buttons ... can someone help? Maybe there is better way to do it, can you explain it to me?


Solution

  • Oscar uses Django's flatpages app, so you can use their template tags to dynamically add in navigation links to the pages you create.

    {% load flatpages %}
    {% get_flatpages as flatpages %}
    
    {% for page in flatpages %}
    <li class="dropdown active">
        <a href="{{ page.url }}" class="dropdown-toggle" {% if not expand_dropdown %} data-toggle="dropdown"{% endif %}>
            {% trans page.title %}
        </a>
    </li>
    {% endfor %}
    

    You can find more information on the flatpages app in the Django flatpage documentation.