Search code examples
pythonodoo

What is the use of slug in odoo


What is slug and why it is used. I'm confused with it. Can anyone help me on it. Thanx

 <p><a t-attf-href="/academy/{{ slug(teacher) }}">
     <t t-esc="teacher.name"/></a>

Solution

  • Transform a string to a slug that can be used in a url path.

    Example:(takem from the website tutorial).

    <a t-attf-href="/academy/{{ slug(teacher) }}">
        <t t-esc="teacher.name"/>
    </a>
    

    You can find more details in slug function documentation.

    Transform a string to a slug that can be used in a url path.

    This method will first try to do the job with python-slugify if present.

    Otherwise it will process string by stripping leading and ending spaces,

    converting unicode chars to ascii, lowering all chars and replacing spaces
    and underscore with hyphen "-".