What I want to do is that I want to change Site display name and domain from example.com to mydomain.com . Normally, I can enter into the django admin and do this. But I want to use data migration. My code is as below:
from django.db import migrations
def change_site_name_from_example_to_mydomain_func(apps, schema_editor):
Site = apps.get_model('sites', 'Site')
site = Site.objects.get(name='example.com')
site.name = 'mydomain.com'
site.domain = 'mydomain.com'
site.save()
class Migration(migrations.Migration):
dependencies = [
('accounts', '0006_populate_database_createsuperuser'),
]
operations = [
migrations.RunPython(change_site_name_from_example_to_mydomain_func),
]
However, I get an error saying that there is no such app as sites. Te question is, how can I use Site model in a data migration?
The error is this:
LookupError: No installed app with label 'sites'.