Monday, May 4 2009 9:49 p.m.
Sometimes, you want to create a custom page for an iPhone or other small phone browser but don't want a custom URL or view for it. This can easily be handled by using the mini_render_to_response function.
This works equally well for any browser that has very little real-estate. It's based on the mini-detector middleware which can be downloaded here here.
mini_render_to_response is a drop in replacement to render_to_response. When using mini_render_to_response it will try to load a version of your template with mini at the end. For example "home_mini.html" instead of "home.html". If it doesn't find the _mini version it falls back to the regular "home.html" version of your template.
The middleware automatically detects if it's a small browser and the function uses this information to attempt to load the mini version of the page. Using this method you can use the same URL and same view to serve the iPhone page.
This is not ideal for every type of site. For example, if the mini template only uses a very small portion of what the view does, you might as well code a different view or at least put a bunch of
More Blog Entries