Skip to content

Instantly share code, notes, and snippets.

@asfaltboy
Created February 9, 2016 07:46
Show Gist options
  • Save asfaltboy/03aea1cd750a8ba99397 to your computer and use it in GitHub Desktop.
Save asfaltboy/03aea1cd750a8ba99397 to your computer and use it in GitHub Desktop.
grep for initial_data
$ grep -R -A 2 -B 2 initial_data *
django/contrib/admin/options.py- return inline_admin_formsets
django/contrib/admin/options.py-
django/contrib/admin/options.py: def get_changeform_initial_data(self, request):
django/contrib/admin/options.py- """
django/contrib/admin/options.py- Get the initial form data.
--
--
django/contrib/admin/options.py- else:
django/contrib/admin/options.py- if add:
django/contrib/admin/options.py: initial = self.get_changeform_initial_data(request)
django/contrib/admin/options.py- form = ModelForm(initial=initial)
django/contrib/admin/options.py- formsets, inline_instances = self._create_formsets(request, form.instance, change=False)
--
--
django/core/management/commands/loaddata.py- self.compression_formats['bz2'] = (bz2.BZ2File, 'r')
django/core/management/commands/loaddata.py-
django/core/management/commands/loaddata.py: # Django's test suite repeatedly tries to load initial_data fixtures
django/core/management/commands/loaddata.py- # from apps that don't have any fixtures. Because disabling constraint
django/core/management/commands/loaddata.py- # checks can be expensive on some database (especially MSSQL), bail
--
--
docs/internals/deprecation.txt- ``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, will be removed.
docs/internals/deprecation.txt-
docs/internals/deprecation.txt:* Support for automatic loading of ``initial_data`` fixtures and initial SQL
docs/internals/deprecation.txt- data will be removed.
docs/internals/deprecation.txt-
--
--
docs/ref/contrib/admin/index.txt- The ``obj_id`` parameter was added.
docs/ref/contrib/admin/index.txt-
docs/ref/contrib/admin/index.txt:.. method:: ModelAdmin.get_changeform_initial_data(request)
docs/ref/contrib/admin/index.txt-
docs/ref/contrib/admin/index.txt- A hook for the initial data on admin change forms. By default, fields are
--
--
docs/ref/contrib/admin/index.txt- ``{'fieldname': 'fieldval'}``::
docs/ref/contrib/admin/index.txt-
docs/ref/contrib/admin/index.txt: def get_changeform_initial_data(self, request):
docs/ref/contrib/admin/index.txt- return {'name': 'custom_initial_value'}
docs/ref/contrib/admin/index.txt-
--
--
docs/releases/1.7.txt- it as soon as possible (nothing more than renaming is required).
docs/releases/1.7.txt-
docs/releases/1.7.txt:* ``initial_data`` fixtures are no longer loaded for apps with migrations; if
docs/releases/1.7.txt- you want to load initial data for an app, we suggest you create a migration for
docs/releases/1.7.txt- your application and define a :class:`~django.db.migrations.operations.RunPython`
--
--
docs/releases/1.7.txt- ``admin_order_field`` value with a hyphen.
docs/releases/1.7.txt-
docs/releases/1.7.txt:* The :meth:`ModelAdmin.get_changeform_initial_data()
docs/releases/1.7.txt: <django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be
docs/releases/1.7.txt- overridden to define custom behavior for setting initial change form data.
docs/releases/1.7.txt-
--
--
docs/releases/1.7.txt-methods are only referring to fields or other items in ``model._meta``.
docs/releases/1.7.txt-
docs/releases/1.7.txt:initial_data
docs/releases/1.7.txt-------------
docs/releases/1.7.txt-
--
--
docs/releases/1.7.txt-------------
docs/releases/1.7.txt-
docs/releases/1.7.txt:Apps with migrations will not load ``initial_data`` fixtures when they have
docs/releases/1.7.txt-finished migrating. Apps without migrations will continue to load these fixtures
docs/releases/1.7.txt-during the phase of ``migrate`` which emulates the old ``syncdb`` behavior,
--
--
docs/releases/1.7.txt-every time you change the schema.
docs/releases/1.7.txt-
docs/releases/1.7.txt:Additionally, like the rest of Django's old ``syncdb`` code, ``initial_data``
docs/releases/1.7.txt-has been started down the deprecation path and will be removed in Django 1.9.
docs/releases/1.7.txt-
--
--
docs/releases/1.9.txt- ``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, are removed.
docs/releases/1.9.txt-
docs/releases/1.9.txt:* Support for automatic loading of ``initial_data`` fixtures and initial SQL
docs/releases/1.9.txt- data is removed.
docs/releases/1.9.txt-
--
--
tests/admin_views/admin.py- view_on_site = False
tests/admin_views/admin.py-
tests/admin_views/admin.py: def get_changeform_initial_data(self, request):
tests/admin_views/admin.py- return {'name': 'overridden_value'}
tests/admin_views/admin.py-
--
--
tests/admin_views/tests.py- self.assertEqual(response.context['form_url'], 'pony')
tests/admin_views/tests.py-
tests/admin_views/tests.py: def test_initial_data_can_be_overridden(self):
tests/admin_views/tests.py- """
tests/admin_views/tests.py- Tests that the behavior for setting initial
--
--
tests/forms_tests/tests/test_forms.py- )
tests/forms_tests/tests/test_forms.py-
tests/forms_tests/tests/test_forms.py: def test_initial_data(self):
tests/forms_tests/tests/test_forms.py- # You can specify initial data for a field by using the 'initial' argument to a
tests/forms_tests/tests/test_forms.py- # Field class. This initial data is displayed when a Form is rendered with *no*
--
--
tests/forms_tests/tests/test_forms.py- self.assertFalse(p.is_valid())
tests/forms_tests/tests/test_forms.py-
tests/forms_tests/tests/test_forms.py: def test_dynamic_initial_data(self):
tests/forms_tests/tests/test_forms.py- # The previous technique dealt with "hard-coded" initial data, but it's also
tests/forms_tests/tests/test_forms.py- # possible to specify initial data after you've already created the Form class
--
--
tests/forms_tests/tests/test_forms.py- )
tests/forms_tests/tests/test_forms.py-
tests/forms_tests/tests/test_forms.py: def test_callable_initial_data(self):
tests/forms_tests/tests/test_forms.py- # The previous technique dealt with raw values as initial data, but it's also
tests/forms_tests/tests/test_forms.py- # possible to specify callable data.
--
--
tests/forms_tests/tests/test_forms.py- self.assertIsNot(field2.fields[0].choices, field.fields[0].choices)
tests/forms_tests/tests/test_forms.py-
tests/forms_tests/tests/test_forms.py: def test_multivalue_initial_data(self):
tests/forms_tests/tests/test_forms.py- """
tests/forms_tests/tests/test_forms.py- #23674 -- invalid initial data should not break form.changed_data()
--
--
tests/forms_tests/tests/test_formsets.py- self.assertTrue(valid_formset.has_changed())
tests/forms_tests/tests/test_formsets.py-
tests/forms_tests/tests/test_formsets.py: def test_formset_initial_data(self):
tests/forms_tests/tests/test_formsets.py- # We can also prefill a FormSet with existing data by providing an ``initial``
tests/forms_tests/tests/test_formsets.py- # argument to the constructor. ``initial`` should be a list of dicts. By default,
--
--
tests/forms_tests/tests/test_formsets.py- self.assertEqual(formset.errors, [{}, {'votes': ['This field is required.']}, {}])
tests/forms_tests/tests/test_formsets.py-
tests/forms_tests/tests/test_formsets.py: def test_more_initial_data(self):
tests/forms_tests/tests/test_formsets.py- # The extra argument also works when the formset is pre-filled with initial
tests/forms_tests/tests/test_formsets.py- # data.
--
--
tests/forms_tests/tests/test_formsets.py- )
tests/forms_tests/tests/test_formsets.py-
tests/forms_tests/tests/test_formsets.py: def test_max_num_with_initial_data(self):
tests/forms_tests/tests/test_formsets.py- # max_num with initial data
tests/forms_tests/tests/test_formsets.py-
--
--
tests/generic_relations/tests.py- GenericFormSet = generic_inlineformset_factory(TaggedItem, extra=1)
tests/generic_relations/tests.py- ctype = ContentType.objects.get_for_model(quartz)
tests/generic_relations/tests.py: initial_data = [{
tests/generic_relations/tests.py- 'tag': 'lizard',
tests/generic_relations/tests.py- 'content_type': ctype.pk,
--
--
tests/generic_relations/tests.py- 'object_id': quartz.pk,
tests/generic_relations/tests.py- }]
tests/generic_relations/tests.py: formset = GenericFormSet(initial=initial_data)
tests/generic_relations/tests.py: self.assertEqual(formset.forms[0].initial, initial_data[0])
tests/generic_relations/tests.py-
tests/generic_relations/tests.py- def test_get_or_create(self):
--
--
tests/generic_views/test_edit.py-
tests/generic_views/test_edit.py-class FormMixinTests(SimpleTestCase):
tests/generic_views/test_edit.py: def test_initial_data(self):
tests/generic_views/test_edit.py- """ Test instance independence of initial data dict (see #16138) """
tests/generic_views/test_edit.py- initial_1 = FormMixin().get_initial()
--
--
tests/model_formsets_regress/tests.py- )
tests/model_formsets_regress/tests.py-
tests/model_formsets_regress/tests.py: def test_initial_data(self):
tests/model_formsets_regress/tests.py- user = User.objects.create(username="bibi", serial=1)
tests/model_formsets_regress/tests.py- UserSite.objects.create(user=user, data=7)
--
--
tests/model_formsets_regress/tests.py- self.assertIsInstance(form.non_field_errors(), ErrorList)
tests/model_formsets_regress/tests.py-
tests/model_formsets_regress/tests.py: def test_initial_data(self):
tests/model_formsets_regress/tests.py- User.objects.create(username="bibi", serial=1)
tests/model_formsets_regress/tests.py- Formset = modelformset_factory(User, fields="__all__", extra=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment