Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.47 KB | None | 0 0
  1. $ grep -R -A 2 -B 2 initial_data *
  2. django/contrib/admin/options.py- return inline_admin_formsets
  3. django/contrib/admin/options.py-
  4. django/contrib/admin/options.py: def get_changeform_initial_data(self, request):
  5. django/contrib/admin/options.py- """
  6. django/contrib/admin/options.py- Get the initial form data.
  7. --
  8. --
  9. django/contrib/admin/options.py- else:
  10. django/contrib/admin/options.py- if add:
  11. django/contrib/admin/options.py: initial = self.get_changeform_initial_data(request)
  12. django/contrib/admin/options.py- form = ModelForm(initial=initial)
  13. django/contrib/admin/options.py- formsets, inline_instances = self._create_formsets(request, form.instance, change=False)
  14. --
  15. --
  16. django/core/management/commands/loaddata.py- self.compression_formats['bz2'] = (bz2.BZ2File, 'r')
  17. django/core/management/commands/loaddata.py-
  18. django/core/management/commands/loaddata.py: # Django's test suite repeatedly tries to load initial_data fixtures
  19. django/core/management/commands/loaddata.py- # from apps that don't have any fixtures. Because disabling constraint
  20. django/core/management/commands/loaddata.py- # checks can be expensive on some database (especially MSSQL), bail
  21. --
  22. --
  23. docs/internals/deprecation.txt- ``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, will be removed.
  24. docs/internals/deprecation.txt-
  25. docs/internals/deprecation.txt:* Support for automatic loading of ``initial_data`` fixtures and initial SQL
  26. docs/internals/deprecation.txt- data will be removed.
  27. docs/internals/deprecation.txt-
  28. --
  29. --
  30. docs/ref/contrib/admin/index.txt- The ``obj_id`` parameter was added.
  31. docs/ref/contrib/admin/index.txt-
  32. docs/ref/contrib/admin/index.txt:.. method:: ModelAdmin.get_changeform_initial_data(request)
  33. docs/ref/contrib/admin/index.txt-
  34. docs/ref/contrib/admin/index.txt- A hook for the initial data on admin change forms. By default, fields are
  35. --
  36. --
  37. docs/ref/contrib/admin/index.txt- ``{'fieldname': 'fieldval'}``::
  38. docs/ref/contrib/admin/index.txt-
  39. docs/ref/contrib/admin/index.txt: def get_changeform_initial_data(self, request):
  40. docs/ref/contrib/admin/index.txt- return {'name': 'custom_initial_value'}
  41. docs/ref/contrib/admin/index.txt-
  42. --
  43. --
  44. docs/releases/1.7.txt- it as soon as possible (nothing more than renaming is required).
  45. docs/releases/1.7.txt-
  46. docs/releases/1.7.txt:* ``initial_data`` fixtures are no longer loaded for apps with migrations; if
  47. docs/releases/1.7.txt- you want to load initial data for an app, we suggest you create a migration for
  48. docs/releases/1.7.txt- your application and define a :class:`~django.db.migrations.operations.RunPython`
  49. --
  50. --
  51. docs/releases/1.7.txt- ``admin_order_field`` value with a hyphen.
  52. docs/releases/1.7.txt-
  53. docs/releases/1.7.txt:* The :meth:`ModelAdmin.get_changeform_initial_data()
  54. docs/releases/1.7.txt: <django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be
  55. docs/releases/1.7.txt- overridden to define custom behavior for setting initial change form data.
  56. docs/releases/1.7.txt-
  57. --
  58. --
  59. docs/releases/1.7.txt-methods are only referring to fields or other items in ``model._meta``.
  60. docs/releases/1.7.txt-
  61. docs/releases/1.7.txt:initial_data
  62. docs/releases/1.7.txt-------------
  63. docs/releases/1.7.txt-
  64. --
  65. --
  66. docs/releases/1.7.txt-------------
  67. docs/releases/1.7.txt-
  68. docs/releases/1.7.txt:Apps with migrations will not load ``initial_data`` fixtures when they have
  69. docs/releases/1.7.txt-finished migrating. Apps without migrations will continue to load these fixtures
  70. docs/releases/1.7.txt-during the phase of ``migrate`` which emulates the old ``syncdb`` behavior,
  71. --
  72. --
  73. docs/releases/1.7.txt-every time you change the schema.
  74. docs/releases/1.7.txt-
  75. docs/releases/1.7.txt:Additionally, like the rest of Django's old ``syncdb`` code, ``initial_data``
  76. docs/releases/1.7.txt-has been started down the deprecation path and will be removed in Django 1.9.
  77. docs/releases/1.7.txt-
  78. --
  79. --
  80. docs/releases/1.9.txt- ``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, are removed.
  81. docs/releases/1.9.txt-
  82. docs/releases/1.9.txt:* Support for automatic loading of ``initial_data`` fixtures and initial SQL
  83. docs/releases/1.9.txt- data is removed.
  84. docs/releases/1.9.txt-
  85. --
  86. --
  87. tests/admin_views/admin.py- view_on_site = False
  88. tests/admin_views/admin.py-
  89. tests/admin_views/admin.py: def get_changeform_initial_data(self, request):
  90. tests/admin_views/admin.py- return {'name': 'overridden_value'}
  91. tests/admin_views/admin.py-
  92. --
  93. --
  94. tests/admin_views/tests.py- self.assertEqual(response.context['form_url'], 'pony')
  95. tests/admin_views/tests.py-
  96. tests/admin_views/tests.py: def test_initial_data_can_be_overridden(self):
  97. tests/admin_views/tests.py- """
  98. tests/admin_views/tests.py- Tests that the behavior for setting initial
  99. --
  100. --
  101. tests/forms_tests/tests/test_forms.py- )
  102. tests/forms_tests/tests/test_forms.py-
  103. tests/forms_tests/tests/test_forms.py: def test_initial_data(self):
  104. tests/forms_tests/tests/test_forms.py- # You can specify initial data for a field by using the 'initial' argument to a
  105. tests/forms_tests/tests/test_forms.py- # Field class. This initial data is displayed when a Form is rendered with *no*
  106. --
  107. --
  108. tests/forms_tests/tests/test_forms.py- self.assertFalse(p.is_valid())
  109. tests/forms_tests/tests/test_forms.py-
  110. tests/forms_tests/tests/test_forms.py: def test_dynamic_initial_data(self):
  111. tests/forms_tests/tests/test_forms.py- # The previous technique dealt with "hard-coded" initial data, but it's also
  112. tests/forms_tests/tests/test_forms.py- # possible to specify initial data after you've already created the Form class
  113. --
  114. --
  115. tests/forms_tests/tests/test_forms.py- )
  116. tests/forms_tests/tests/test_forms.py-
  117. tests/forms_tests/tests/test_forms.py: def test_callable_initial_data(self):
  118. tests/forms_tests/tests/test_forms.py- # The previous technique dealt with raw values as initial data, but it's also
  119. tests/forms_tests/tests/test_forms.py- # possible to specify callable data.
  120. --
  121. --
  122. tests/forms_tests/tests/test_forms.py- self.assertIsNot(field2.fields[0].choices, field.fields[0].choices)
  123. tests/forms_tests/tests/test_forms.py-
  124. tests/forms_tests/tests/test_forms.py: def test_multivalue_initial_data(self):
  125. tests/forms_tests/tests/test_forms.py- """
  126. tests/forms_tests/tests/test_forms.py- #23674 -- invalid initial data should not break form.changed_data()
  127. --
  128. --
  129. tests/forms_tests/tests/test_formsets.py- self.assertTrue(valid_formset.has_changed())
  130. tests/forms_tests/tests/test_formsets.py-
  131. tests/forms_tests/tests/test_formsets.py: def test_formset_initial_data(self):
  132. tests/forms_tests/tests/test_formsets.py- # We can also prefill a FormSet with existing data by providing an ``initial``
  133. tests/forms_tests/tests/test_formsets.py- # argument to the constructor. ``initial`` should be a list of dicts. By default,
  134. --
  135. --
  136. tests/forms_tests/tests/test_formsets.py- self.assertEqual(formset.errors, [{}, {'votes': ['This field is required.']}, {}])
  137. tests/forms_tests/tests/test_formsets.py-
  138. tests/forms_tests/tests/test_formsets.py: def test_more_initial_data(self):
  139. tests/forms_tests/tests/test_formsets.py- # The extra argument also works when the formset is pre-filled with initial
  140. tests/forms_tests/tests/test_formsets.py- # data.
  141. --
  142. --
  143. tests/forms_tests/tests/test_formsets.py- )
  144. tests/forms_tests/tests/test_formsets.py-
  145. tests/forms_tests/tests/test_formsets.py: def test_max_num_with_initial_data(self):
  146. tests/forms_tests/tests/test_formsets.py- # max_num with initial data
  147. tests/forms_tests/tests/test_formsets.py-
  148. --
  149. --
  150. tests/generic_relations/tests.py- GenericFormSet = generic_inlineformset_factory(TaggedItem, extra=1)
  151. tests/generic_relations/tests.py- ctype = ContentType.objects.get_for_model(quartz)
  152. tests/generic_relations/tests.py: initial_data = [{
  153. tests/generic_relations/tests.py- 'tag': 'lizard',
  154. tests/generic_relations/tests.py- 'content_type': ctype.pk,
  155. --
  156. --
  157. tests/generic_relations/tests.py- 'object_id': quartz.pk,
  158. tests/generic_relations/tests.py- }]
  159. tests/generic_relations/tests.py: formset = GenericFormSet(initial=initial_data)
  160. tests/generic_relations/tests.py: self.assertEqual(formset.forms[0].initial, initial_data[0])
  161. tests/generic_relations/tests.py-
  162. tests/generic_relations/tests.py- def test_get_or_create(self):
  163. --
  164. --
  165. tests/generic_views/test_edit.py-
  166. tests/generic_views/test_edit.py-class FormMixinTests(SimpleTestCase):
  167. tests/generic_views/test_edit.py: def test_initial_data(self):
  168. tests/generic_views/test_edit.py- """ Test instance independence of initial data dict (see #16138) """
  169. tests/generic_views/test_edit.py- initial_1 = FormMixin().get_initial()
  170. --
  171. --
  172. tests/model_formsets_regress/tests.py- )
  173. tests/model_formsets_regress/tests.py-
  174. tests/model_formsets_regress/tests.py: def test_initial_data(self):
  175. tests/model_formsets_regress/tests.py- user = User.objects.create(username="bibi", serial=1)
  176. tests/model_formsets_regress/tests.py- UserSite.objects.create(user=user, data=7)
  177. --
  178. --
  179. tests/model_formsets_regress/tests.py- self.assertIsInstance(form.non_field_errors(), ErrorList)
  180. tests/model_formsets_regress/tests.py-
  181. tests/model_formsets_regress/tests.py: def test_initial_data(self):
  182. tests/model_formsets_regress/tests.py- User.objects.create(username="bibi", serial=1)
  183. tests/model_formsets_regress/tests.py- Formset = modelformset_factory(User, fields="__all__", extra=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement