Hi,
Please look this sugest to exclude some field in DetailView, to dont show any field.
usage:
In MyCrud(BaseCrudBuilder):
etailview_excludes = [ 'parent','mptt_level', 'id', ]
and this fields wont show in detail.
Resume:
In tags.py
add a exclude parameter
get_model_fields(obj, exclude=[]):
...
getattr(model, name, None), property
):
property_fields.append(Field(name=name, verbose_name=name))
ret = chain(obj._meta.fields, property_fields)
return [i for i in ret if i.name not in exclude]
In template:
add a context variable with a list of exclude fields.
{% for field in object|get_model_fields:exclude %}
In view.py
def generate_detail_view(self):
add :
detailview_excludes = self.detailview_excludes,
in abstract.py
class BaseBuilder(object):
self.detailview_excludes = self._has_crud_attr('detailview_excludes')
and finaly in mixin.py
class CrudBuilderMixin
def get_context_data(
try:
context['exclude'] = self.detailview_excludes
except:
context['exclude'] =None
Coverage increased (+0.2%) to 79.167% when pulling a293b7663f77caab9530239d74562549822c5092 on marcoshemann:master into c965ec5c7a46773c03134d6c10702945e42d05c3 on asifpy:master.
Coverage increased (+0.2%) to 79.167% when pulling a293b7663f77caab9530239d74562549822c5092 on marcoshemann:master into c965ec5c7a46773c03134d6c10702945e42d05c3 on asifpy:master.
Hi, Please look this sugest to exclude some field in DetailView, to dont show any field. usage: In MyCrud(BaseCrudBuilder): etailview_excludes = [ 'parent','mptt_level', 'id', ]
and this fields wont show in detail.
Resume: In tags.py add a exclude parameter get_model_fields(obj, exclude=[]): ... getattr(model, name, None), property ): property_fields.append(Field(name=name, verbose_name=name)) ret = chain(obj._meta.fields, property_fields) return [i for i in ret if i.name not in exclude]
In template: add a context variable with a list of exclude fields. {% for field in object|get_model_fields:exclude %}
In view.py def generate_detail_view(self): add : detailview_excludes = self.detailview_excludes,
in abstract.py class BaseBuilder(object): self.detailview_excludes = self._has_crud_attr('detailview_excludes')
and finaly in mixin.py class CrudBuilderMixin def get_context_data( try: context['exclude'] = self.detailview_excludes except: context['exclude'] =None