Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit d5f1d6f937ea1649fce97c99b07f82b55cec1e01 1 parent 4df380f
@malcolmt malcolmt authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 tests/modeltests/model_formsets/models.py
View
5 tests/modeltests/model_formsets/models.py
@@ -254,19 +254,20 @@ class CustomPrimaryKey(models.Model):
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': '',
Please sign in to comment.
Something went wrong with that request. Please try again.