﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29515	put sample code in empty migrations	Chris Curvey	nobody	"SHORT VERSION:  put sample code into the generated file when creating an ""empty"" migration, like this:

#def combine_names(apps, schema_editor):
#    # We can't import the Person model directly as it may be a newer
#    # version than this migration expects. We use the historical version.
#    Person = apps.get_model('yourappname', 'Person')
#    for person in Person.objects.all():
#        person.name = '%s %s' % (person.first_name, person.last_name)
#        person.save()


and then

    operations = [
        #migrations.RunPython(combine_names),
    ]

LONG VERSION/JUSTIFICATION:

Every time I create a data migration (python manage.py makemigrations foo --empty), I have to do a web search to remember what the parameters are to the function I want to call (apps, schema_editor), and how to use those parameters, and how to get the code to actually run (migrations.RunPython).  

It would be really nice to have that sample code just put into the empty migration so that it is there as an example.





"	New feature	new	Uncategorized	2.0	Normal				Unreviewed	0	0	0	0	0	0
