1 2 3 4 5 6 7 8 9 10 11 12 13 | def template_callable(func):
class GetAttrCaller(object):
def __init__(self, instance):
self.instance = instance
def __getattr__(self, name):
return func(self.instance, name)
# Would cause Django to think this is a method, even through templates
#def __call__(self, *args, **kwargs):
# return func(self, *args, **kwargs)
class TemplateCallableDescriptor(object):
def __get__(self, instance, klass):
return GetAttrCaller(instance)
return TemplateCallableDescriptor()
|
More like this
- Tags & filters for rendering search results by exogen 3 years, 10 months ago
- if tag with method call by dahool 2 years, 9 months ago
- A ModelChoiceField with support for title in options based on a field in the model by celopes 1 year, 6 months ago
- Template tag: Extend with parameters by miracle2k 4 years, 3 months ago
- Markdown and Syntax Highlighting in Django by blinks 4 years, 10 months ago
Comments
HI,
Iam new to python and django.
Here i need to enable radio buttons on home screen depending on data stored in model database. How we can do this to get data in database and enabling radio buttons on same screen?
For example i have to choose role which is not filled already.
Plz help me.
my mail gvkreddy.reddy@gmail.com
Thanks in advance by vamsi
#