Server error from deleting example.com site - native

Hi,
I accidentally deleted ‘example.com’ site under /admin after creating a new site name. After click save then I got ‘500 internal server error’. I remember did this before in the past but just reinstalled to get it worked again. I searched around but couldn’t find the answer to why example.com site name cannot be deleted. Or I miss some step after or before deleting it? Appreciated if someone can provide me a link explaining about this or know to fix this error and not have to reinstall the whole thing over again.

Many thanks,
Monti

You can create the record from mysql command line.

I think this happens because you are missing the SITE_ID=1, which Django use by default. You can try adding in your settings file (production.py/aws.py/XX.py) SITE_ID=2, or another valid number (If you don’t have any site configured, you should add one by hand into the MySQL database).

2 Likes

@felipe.espinoza.r I did the same mistake by deleting the ‘example.com’ and no other site is configured which ended in throwing error:500 . I gone through the solution provided by you. But have a question as you told to add one again in MYSQL database, so it should get added in which table? . Sorry if this question makes no sense to you , but i am new to this.

The tables is called “django_site” in edxapp.

@felipe.espinoza.r I checked for the table ‘django_site’ under bitnami_edxapp . But on doing desc django_site , I didn’t find the schema of the table. So can you please help me out with the schema of the table?

Actually, there is no need to dive directly into the DB shell.
If you have any chance to enter the Django shell you still can re-create the deleted Site record from there:

>>> from django.contrib.sites.models import Site
>>> Site.objects.create(id=1, domain='example.com', name='example.com')

Notice explicit id attr, so DB won’t use another computed value.