That thought had occurred to me about mobile phones vs tablets, but I didn't 
want to get too complex with this right away. However, you are correct that 
many sites have an iPhone/mobile site, and iPad site, and a desktop site. I 
think I'll try to expand my patch to replace request.is_mobile with 
request.browser_class, which could equal 'desktop', 'mobile', or 'tablet'. A 
request from an iPad would first check for 'tablet' views, then 'mobile' 
views, and finally 'desktop' views. How does that sound?

As for the directory structure, I suppose we could do something like this:

views/
    _mobile/
        default/
        other_controller/
    _tablet/
        default/
        other_controller/
    default/
    other_controller/

Or even put the devices into an main '_devices' folder:

views/
    _devices/
        _mobile/
            ...
        _tablet/
            ...
    default/
    other_controller/

The only issue I'm having with this is with the layouts. In order for this 
to work with byte compile, I actually had to turn the layout.html file into 
this:

{{if is_mobile:}}
    <!-- All mobile HTML -->
{{else:}}
    <!-- rest of original layout.html file -->
{{pass}}

I tried breaking it into desktop.html and mobile.html, then in layout.html:
{{if is_mobile:}}
    {{include 'mobile.html'}}
{{else:}}
    {{include 'desktop.html'}}
{{pass}}

Unfortunately, in the desktop.html or mobile.html, the {{include}} line that 
includes the view content is ignored, so I had to put everything into a 
single layout.html file.

Reply via email to