Skip to content

Commit

Permalink
major bug fix in detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
asifpy committed Oct 30, 2016
1 parent fc31cd3 commit fc49973
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crudbuilder/templatetags/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_value(obj, field):


@register.filter
def get_model_fields(obj, exclude=[]):
def get_model_fields(obj, detail_exclude=None):
model = obj.__class__
excludes = ['pk']

Expand All @@ -39,8 +39,11 @@ def 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]
fields = chain(obj._meta.fields, property_fields)

if detail_exclude:
fields = [field for field in fields if field.name not in detail_exclude]
return fields


@register.filter
Expand Down
1 change: 1 addition & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ CRUD class Attributes
- **tables2_css_class** -- CSS class for list view table (for django-tables2)
- **tables2_pagination** -- By default crudbuilder will set pagination to 10, you can oveeride this value by setting this attribute
- **modelform_excludes** -- Exclude fields for model form
- **detailview_excludes** -- Exclude fields in Deatail view
- **custom_modelform** -- Your custom model form
- **custom_table2** -- Your custom Tables2 class
- **custom_templates** -- Your own custom templates. For more details on custom templates, you can check check :doc:`custom templates </templates>`
Expand Down
1 change: 1 addition & 0 deletions example/example/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PersonCrud(BaseCrudBuilder):
modelform_excludes = ['created_by', 'updated_by']
login_required = True
permission_required = True
# detailview_excludes = ['img']
# inlineformset = PersonEmploymentInlineFormset

# custom_templates = {
Expand Down

0 comments on commit fc49973

Please sign in to comment.