def router(request, function, module):
    m = __import__(module, globals(), locals(), [function.lower()])
try:
    return m.__dict__[function.lower()](request)
except KeyError:
    raise Http404()
Django: How do I create a generic url routing to views?