Foreign Key Rendering in Django

Asked

Viewed 146 times

2

I am using Createview on Jango and rendering my components with Tweak widget I would like to know if you have any way to exchange this first combo option

rendered form in the template

{% render_field form.category class="form-control" %}

inserir a descrição da imagem aqui

  • You want to exchange this default value of ----------?

1 answer

0

You can use the initial, see:

>>> import datetime
>>> class DateForm(forms.Form):
...     day = forms.DateField(initial=datetime.date.today)

Or so for a text:

>>> class CommentForm(forms.Form):
...     name = forms.CharField()
...     url = forms.URLField()
...     comment = forms.CharField()
>>> default_data = {'name': 'Your name', 'url': 'http://'}
>>> f = CommentForm(default_data, auto_id=False)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.