Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » How do I specify default value for a form field while using manipulator [RSS Feed]

#1 Nov. 22, 2005 11:37:05

Cheng Z.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How do I specify default value for a form field while using manipulator


How do I specify default value for a form field, which maps to aforeign key as Poll.submitted_user shown below, with manipulator, inparticular AddManipulator? I couldn't find relevant information fromthe 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 beselected as 'test1' automatically. It would be better if this fieldis disabled or hidden from the page.Currently, I have no idea how to do so. Any suggestions will beappreciated. Thanks a lot.- Cheng

Offline

#2 Nov. 22, 2005 13:21:27

Grigory F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How do I specify default value for a form field while using manipulator


Hello Cheng Zhang!
On Tue, 22 Nov 2005 19:36:52 +0800 you wrote:

> 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.http://code.djangoproject.com/wiki/CookBookManipulatorsthere are two
ways to do this stuff.

--
Всего наилучшего!
greg anastasia ru Григорий.

Offline

#3 Nov. 22, 2005 14:05:59

Cheng Z.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

How do I specify default value for a form field while using manipulator


Thanks. Guess I should get the habit of searching wiki, esp. thecookbook.On Nov 22, 2005, at 9:21 PM, Grigory Fateyev wrote:http://code.djangoproject.com/wiki/CookBookManipulatorsthere are two
ways to do this stuff.

Offline

  • Root
  • » Django
  • » How do I specify default value for a form field while using manipulator [RSS Feed]

Board footer

Moderator control

Enjoy the 27th of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support