I want to do following:
u=reverse_lazy('xyz')
isinstance(u,str) # this is false since u is an object.
type(u) # <class 'django.utils.functional.lazy.<locals>.__proxy__'>
isinstance(u,<class 'django.utils.functional.lazy.<locals>.__proxy__'>) # doesnt work
CodePudding user response:
Doing u.__dict__
you will get the following dict:
{'_proxy____args': ('xyz',), '_proxy____kw': {}}
With that, you can get the initial args and then get the types of them.
u=reverse_lazy('xyz')
initial_arg = u._proxy____args[0]
print(initial_arg)
# 'xyz'
print(type(initial_arg))
# <class 'str'>