Git Product home page Git Product logo

django-mobile-helper's Introduction

django-mobile-helper

Helps django developers to support mobile users, features:

  • Detection of requests starting with m. or mobile.yoursite.com
  • Detection of requests with HTTP_USER_AGENT of mobile browsers
  • Decorator to provide a simple way provide template for mobile devices

See project page for more.

Installation

Download the code; put in into your project’s directory,
if you want a system-wide instalation you can run

python setup.py install
or
sudo easy_install django-mobile-helper

REQUIREMENTS: django !

SETTINGS.py

MOBILE_PATTERN

Regular expression to match mobile user in HTTP_USER_AGENT header.
default: (up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|netfront)

USAGE

MIDDLEWARE

In your settings.py add:


MIDDLEWARE_CLASSES = (
(…) #your middleware classes
# if you added to you project’s folder:
‘your_project.django_mobile.middleware.MobileMiddleware’
# if you installed on site-packages:
‘django_mobile.middleware.MobileMiddleware’
)

DECORATOR

You can use it in any view function:


from django_mobile.middleware import MobileMiddleware
@login_required
@render_to(template=‘desktop.html’, mobile_template=‘mobile_template.html’)
def view_function(request):
(…) # do your stuff here
return locals()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.