djangodjango-modelsdjango-sites

Changing default Django site name and domain from example.com to the proper ones


According to the Django documentation (here):

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.

Isn't it safe to directly change the default values from the Django admin panel? why?


Solution

  • Here is my answer. First option is to change them on Django Admin site. Second option is to create a migration file manually and run your migrations. Let me describe the second option here. Firstly, create an empty migration using following command.

    $ python manage.py makemigrations --empty --name update_site_name app_name
    

    Next, refer to this blog to edit the migration file.

    Finally, run your migrations.

    Thank you.