Fixed #8542 -- Made the model_formstests tests from [8528] a little less
dependent upon the precise values of auto-created primary key integers. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8563 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4df380ff01
commit
d5f1d6f937
|
@ -254,19 +254,20 @@ used.
|
|||
True
|
||||
>>> formset.save()
|
||||
[<BetterAuthor: Ernest Hemingway>]
|
||||
>>> hemingway_id = BetterAuthor.objects.get(name="Ernest Hemingway").pk
|
||||
|
||||
>>> formset = BetterAuthorFormSet()
|
||||
>>> for form in formset.forms:
|
||||
... print form.as_p()
|
||||
<p><label for="id_form-0-name">Name:</label> <input id="id_form-0-name" type="text" name="form-0-name" value="Ernest Hemingway" maxlength="100" /></p>
|
||||
<p><label for="id_form-0-write_speed">Write speed:</label> <input type="text" name="form-0-write_speed" value="10" id="id_form-0-write_speed" /><input type="hidden" name="form-0-author_ptr_id" value="4" id="id_form-0-author_ptr_id" /></p>
|
||||
<p><label for="id_form-0-write_speed">Write speed:</label> <input type="text" name="form-0-write_speed" value="10" id="id_form-0-write_speed" /><input type="hidden" name="form-0-author_ptr_id" value="..." id="id_form-0-author_ptr_id" /></p>
|
||||
<p><label for="id_form-1-name">Name:</label> <input id="id_form-1-name" type="text" name="form-1-name" maxlength="100" /></p>
|
||||
<p><label for="id_form-1-write_speed">Write speed:</label> <input type="text" name="form-1-write_speed" id="id_form-1-write_speed" /><input type="hidden" name="form-1-author_ptr_id" id="id_form-1-author_ptr_id" /></p>
|
||||
|
||||
>>> data = {
|
||||
... 'form-TOTAL_FORMS': '2', # the number of forms rendered
|
||||
... 'form-INITIAL_FORMS': '1', # the number of forms with initial data
|
||||
... 'form-0-author_ptr_id': '4',
|
||||
... 'form-0-author_ptr_id': hemingway_id,
|
||||
... 'form-0-name': 'Ernest Hemingway',
|
||||
... 'form-0-write_speed': '10',
|
||||
... 'form-1-author_ptr_id': '',
|
||||
|
|
Loading…
Reference in New Issue