dimanche 28 juin 2015

Django UpdatView - custom form fields

I have my UpdateView for updating some of my data.

class WpisUpdate(UpdateView):
model=ProdukcjaStanTb
fields=[
        'temat',
        'podtemat',
        'proc_wym',
        'proc_auto',
        'proc_palnik',
        'proc_uruch',
        'proc_pakowanie',
        ]

Now, in my template I'd like to have only :

'proc_wym',
'proc_auto
'proc_palnik',
'proc_uruch',
'proc_pakowanie',

Fields, but also have access to fields "temat" and "podtemat" (to make big titles or web page title for example). In template i'm using {{form.temat.value}} tags, which are ok, but requires those fields in field list in UpdateView. I don't want user to change that. Is there any quick way to have those fields hidden in form but accessible while using easy:

{{ form.as_p }}

in template ? Or do i have to manually edit my form and add some html attributes, like read-only or input type="hidden" ?

Aucun commentaire:

Enregistrer un commentaire