web2py has a more flexible template engine, you can use Python there and
does not need to create a tons of template filters to get simple things
done. Also in Django the template language sucks a lot because of the
limitations.

Let me give an example:

To build a map using google maps API you have to inform the lat/long, for
some reason in my database the information was stored as "-23,4500" google
maps does not accept it with the comma, so it is easy with Python and
web2py.

<script>
map = new GMap({"lat":* {{=myplace.lat.replace(",", ".")}}*, .....)
</script>

As you can see web2py allowed me to use pure Python code for this.. lets
try this in Django...

1. Put the template tags configuration in your settings.py
2. Create a directory called templatetags there
3. Create a module for your template tag
4. import, register, decorate and create your template tag

from django import template

register = template.Library()

@register.filter
def replace(value, args):
    value = str(value)
    args = str(args)
    try:
        search, replace = args.split("|")
    except Exception:
        return value
    else:
        return value.replace(search, replace)

Template tags/filters are limited functions which receives only one
argument, so you have to receive this as string to be able to split them un
multiple args.

5. Now in your template file you can use the simple "replace" feature in a
weird way

<script>
map = new GMap({"lat":* {{ myplace.lat | replace: ",|." }}*, .....)
</script>

web2py templates are also very good for some other reasons:

- it allows to create HTML functions
- It has a nice block system
- It allows us to use PURE PYTHON to solve simple things!



On Wed, Aug 1, 2012 at 12:57 PM, vinicius...@gmail.com <
vinicius...@gmail.com> wrote:

> We2bpy strengths over Django:
>
> 1) Automatic migrations. It enforces baby steps design just
> out-of-the-box. South migrations is a powerful tool, but Django doesn't
> have it natively yet.
> 2) Web2py shows a generic template when you don't have one created. Yet,
> baby steps guaranteed.
>
> I see these 2 as good features to Web2py newbies.
>
>
> --
> Vinicius Assef
>
>
>
>
> On 08/01/2012 12:46 PM, Alec Taylor wrote:
>
>> Tonight I'm going to present my little social-network to a user-group.
>>
>> I'm going to show them my code, some slides, the website, the mobile
>> apps and tell them when Django isn't as good as web2py.
>>
>> Are there any particular features of web2py you would recommend I
>> highlight? - Also, are there any major drawbacks in Django that web2py
>> has that is easily advertisable?
>>
>> (I have a slide or two on this, but I'm sure as longtime
>> users/developers of web2py you'd have more to pitch-in)
>>
>> Thanks for all information,
>>
>> Alec Taylor
>>
>> --
>>
>>
>>
>>
> --
>
>
>
>

-- 



Reply via email to