﻿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
31629	Sites framework post_migrate signal overwrites user created site.	Tom Carrick	nobody	"There is some advice in the documentation:

> `django.contrib.sites` registers a `post_migrate` signal handler which creates a default site named `example.com` with the domain `example.com`. This site will also be created after Django creates the test database. To set the correct name and domain for your project, you can use a data migration.

This advice can be quite contradictory. It only works if you've already run migrations once before adding the data migration, so it doesn't work for new deployments. This is because creating the default site will overwrite what is currently there, as the post_migrate signal runs after the user's data migration.

I think that `create_default_site()` shouldn't overwrite any data, it should only create the site if the table is empty, or at least only if the id isn't already in use.

If the current behaviour is intentional for some reason, I think we should at least remove the advice to create a data migration from the docs."	Bug	closed	contrib.sites	dev	Normal	invalid			Unreviewed	0	0	0	0	0	0
