Here are the examples of the python api django.urls.get_mod_func taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
View Complete Implementation : views.py
Copyright MIT License
Author : rizwansoaib
Copyright MIT License
Author : rizwansoaib
@staticmethod
def _get_view_func(view):
urlconf = get_urlconf()
if get_resolver(urlconf)._is_callback(view):
mod, func = get_mod_func(view)
try:
# Separate the module and function, e.g.
# 'mymodule.views.myview' -> 'mymodule.views', 'myview').
return getattr(import_module(mod), func)
except ImportError:
# Import may fail because view contains a clast name, e.g.
# 'mymodule.views.ViewContainer.my_view', so mod takes the form
# 'mymodule.views.ViewContainer'. Parse it again to separate
# the module and clast.
mod, klast = get_mod_func(mod)
return getattr(getattr(import_module(mod), klast), func)
0
View Complete Implementation : views.py
Copyright MIT License
Author : bpgc-cte
Copyright MIT License
Author : bpgc-cte
@staticmethod
def _get_view_func(view):
urlconf = get_urlconf()
if get_resolver(urlconf)._is_callback(view):
mod, func = get_mod_func(view)
try:
# Separate the module and function, e.g.
# 'mymodule.views.myview' -> 'mymodule.views', 'myview').
return getattr(import_module(mod), func)
except ImportError:
# Import may fail because view contains a clast name, e.g.
# 'mymodule.views.ViewContainer.my_view', so mod takes the form
# 'mymodule.views.ViewContainer'. Parse it again to separate
# the module and clast.
mod, klast = get_mod_func(mod)
return getattr(getattr(import_module(mod), klast), func)
except AttributeError:
# PY2 generates incorrect paths for views that are methods,
# e.g. 'mymodule.views.ViewContainer.my_view' will be
# listed as 'mymodule.views.my_view' because the clast name
# can't be detected. This causes an AttributeError when
# trying to resolve the view.
return None