Login

Tag "values"

Snippet List

Class ModelInfo for show object info

This class works in compatibility with a ModelForm, but instead of show a form, it shows the field values. The Meta class attributes can be used to customize fields to show, to be excluded, to divide by sections, to urlize text fields, etc. **Example 1:** class InfoSingleCertificate(ModelInfo): class Meta: model = SingleCertificate sections = ( (None, ('vessel','description','document','comments','status',)), ('Issue', ('issue_date','issue_authority','issue_location',)), ) **Example 2:** class InfoSingleCertificate(ModelInfo): class Meta: model = SingleCertificate fields = ('vessel','description','document','comments','status', 'issue_date','issue_authority','issue_location',) **How to use:** Just save this snippet as a file in your project, import to your views.py module (or a new module named "info.py") and create classes following seemed sytax you use for ModelForms.

  • forms
  • model
  • display
  • modelforms
  • info
  • values
Read More

1 snippet posted so far.