Thanks for your response. Currently I am dealing with a form with individual field permissions. I guess it explains it gets difficult with Django Form, which are made for only editing. I know a custom read-only field can be created in the code below. I am still struggling with post the form with labels not fields. As I newcomer to Django, it's very convenient to have these capabilities on a regular with simple form permissions. But once it gets bit more complicated in security, Form object is not very helpful or i maybe am missing a point.
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.forms.util import flatatt
class ReadOnlyWidget(forms.Widget):
def render(self, name, value, attrs):
final_attrs = self.build_attrs(attrs, name=name)
if hasattr(self, 'initial'):
value = self.initial
return mark_safe("<p %s>%s</p>" % (flatatt(final_attrs), escape(value) or ''))
def _has_changed(self, initial, data):
return False
class ReadOnlyField(forms.Field):
widget = ReadOnlyWidget
def __init__(self, widget=None, label=None, initial=None, help_text=None):
super(type(self), self).__init__(self, label=label, initial=initial,
help_text=help_text, widget=widget)
self.widget.initial = initial
def clean(self, value):
return self.widget.initial