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

1.1k views Asked by At

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?

2

There are 2 answers

0
Venus713 On BEST ANSWER

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.

0
mahyard On

Finally, I changed the site_name directly in my database. I realized that a site can have a migration to define a default site_name from scratch, but for a case like mine in which there are a lot of data it's not necessary to add a migration. In other words, you should add a migration when you are developing your site, not when it's on the production stage.

Thanks to @markwalker for his comment