Задать вопрос

Тел: +7 965 3737 888

443

Просмотров

2

Ответов

Class ModelInfo for show object info

<p>This class works in compatibility with a ModelForm, but instead of show a form, it shows the field values.</p>
<p>The Meta class attributes can be used to customize fields to show, to be excluded, to divide by sections, to urlize text fields, etc.</p>
<p><strong>Example 1:</strong></p>
class InfoSingleCertificate(ModelInfo):
    class Meta:
        model = SingleCertificate
        sections = (
            (None, ('vessel','description','document','comments','status',)),
            ('Issue', ('issue_date','issue_authority','issue_location',)),
        )

<p><strong>Example 2:</strong></p>
class InfoSingleCertificate(ModelInfo):
    class Meta:
        model = SingleCertificate
        fields = ('vessel','description','document','comments','status',
            'issue_date','issue_authority','issue_location',)

<p><strong>How to use:</strong></p>
<p>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.</p>

Вопрос полезен? Да0/Нет0
file_2976.py(3.7Кб)
None

Ответы (2):

Ответwandersean:18.08.2010
Ответ полезен? Да0/Нет0

I'm using this, thanks marinho.

One question: It's been a while since you posted this, are you still using it, or is there now a better way to get this info easily?

Ответmarinho:04.07.2008
Ответ полезен? Да0/Нет0

Fixed methods get_model_fields and get_field