How do I specify default value for a form field, which maps to a
foreign key as Poll.submitted_user shown below, with manipulator, in
particular AddManipulator? I couldn't find relevant information from
the django-users archive, at least searching with keywords:
manipulator, default didn't help.
My model is:
class Poll(meta.Model):
question = meta.CharField(maxlength=200)
pub_date = meta.DateTimeField('date published')
submitted_user = meta.ForeignKey(users.User)
In the template for creating a poll, I use the form manipulator of
'coz. Partially it is:
<form method="post" action=".">
<p>
<label for="id_question">question:</label> {{ form.question }}
{% if form.question.errors %}*** {{ form.question.errors|join:",
" }}{% endif %}
</p>
<p>
<label for="id_pub_date">pub_date:</label> {{ form.pub_date }}
{% if form.pub_date.errors %}*** {{ form.pub_date.errors|join:",
" }}{% endif %}
</p>
<p>
<label for="id_submitted_user">submitted_user:</label>
{{ form.submitted_user }}
{% if form.submitted_user.errors %}***
{{ form.submitted_user.errors|join:", " }}{% endif %}
</p>
<input type="submit" />
</form>
To add a new poll, when I login as a user, say 'test1', I want the
'submitted_user' form field (render as a pulldown list) to be
selected as 'test1' automatically. It would be better if this field
is disabled or hidden from the page.
Currently, I have no idea how to do so. Any suggestions will be
appreciated. Thanks a lot.
- Cheng