Fixed #31007 -- Allowed specifying type of auto-created primary keys.

This also changes the default type of auto-created primary keys
for new apps and projects to BigAutoField.
This commit is contained in:
Tom Forbes 2020-07-12 13:59:57 +01:00 committed by Mariusz Felisiak
parent b960e4ed72
commit b5e12d490a
28 changed files with 415 additions and 11 deletions

View file

@ -61,6 +61,7 @@ class AdminScriptTestCase(SimpleTestCase):
settings_file.write("%s\n" % extra)
exports = [
'DATABASES',
'DEFAULT_AUTO_FIELD',
'ROOT_URLCONF',
'SECRET_KEY',
]
@ -2188,6 +2189,20 @@ class StartApp(AdminScriptTestCase):
"won't replace conflicting files."
)
def test_template(self):
out, err = self.run_django_admin(['startapp', 'new_app'])
self.assertNoOutput(err)
app_path = os.path.join(self.test_dir, 'new_app')
self.assertIs(os.path.exists(app_path), True)
with open(os.path.join(app_path, 'apps.py')) as f:
content = f.read()
self.assertIn('class NewAppConfig(AppConfig)', content)
self.assertIn(
"default_auto_field = 'django.db.models.BigAutoField'",
content,
)
self.assertIn("name = 'new_app'", content)
class DiffSettings(AdminScriptTestCase):
"""Tests for diffsettings management command."""