Skip to content

Commit fc49973

Browse files
committed
major bug fix in detail view
1 parent fc31cd3 commit fc49973

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

crudbuilder/templatetags/tags.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_value(obj, field):
2929

3030

3131
@register.filter
32-
def get_model_fields(obj, exclude=[]):
32+
def get_model_fields(obj, detail_exclude=None):
3333
model = obj.__class__
3434
excludes = ['pk']
3535

@@ -39,8 +39,11 @@ def get_model_fields(obj, exclude=[]):
3939
getattr(model, name, None), property
4040
):
4141
property_fields.append(Field(name=name, verbose_name=name))
42-
ret = chain(obj._meta.fields, property_fields)
43-
return [i for i in ret if i.name not in exclude]
42+
fields = chain(obj._meta.fields, property_fields)
43+
44+
if detail_exclude:
45+
fields = [field for field in fields if field.name not in detail_exclude]
46+
return fields
4447

4548

4649
@register.filter

docs/source/installation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ CRUD class Attributes
9797
- **tables2_css_class** -- CSS class for list view table (for django-tables2)
9898
- **tables2_pagination** -- By default crudbuilder will set pagination to 10, you can oveeride this value by setting this attribute
9999
- **modelform_excludes** -- Exclude fields for model form
100+
- **detailview_excludes** -- Exclude fields in Deatail view
100101
- **custom_modelform** -- Your custom model form
101102
- **custom_table2** -- Your custom Tables2 class
102103
- **custom_templates** -- Your own custom templates. For more details on custom templates, you can check check :doc:`custom templates </templates>`

example/example/crud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class PersonCrud(BaseCrudBuilder):
2323
modelform_excludes = ['created_by', 'updated_by']
2424
login_required = True
2525
permission_required = True
26+
# detailview_excludes = ['img']
2627
# inlineformset = PersonEmploymentInlineFormset
2728

2829
# custom_templates = {

0 commit comments

Comments
 (0)