or

Generating Lorem Ipsums in Django Templates

When we first attempt create our web applications, most of us use a common printing phrase which starts with Lorem Ipsum words in our templates. Today while I was reading something in the Django documentation, and surprisingly I came across with this very useful module. Honestly, I didn’t even know Django has such a thing. After seeing this module, I again thought about how much I love Django :)

Anyways, the idea is generating this placeholder words in your template by using a template tag. Here is the usage:

<!-- 
    make sure you're loading webdesign module 
    by writing {% load webdesign %} 
-->
<div id='my-text-area'>
   {% lorem %}
   <!--
       This will be replaced with "Lorem ipsum dolor 
       sit amet, consectetur adipiscing elit..."
   -->
</div>

<input type='text name='name' value='{% lorem 2 w random %}' /> <!-- This will be replaced with 2 random latin words -->

<div id='description'> {% lorem 5 p %} <!-- This will be replaced with 5 paragraphs of "Lorem Ipsum.." text --> </div>

Isn’t Django awesome :) It has everything you need!



Leave a Reply

Name (required)
Mail (required)
Website