[Fixed]-How to configure Django to access remote MySQL db django.contrib.sites.RequestSite module missing

1👍

The error you’re seeing has nothing to do with your database settings (assuming your real code has the actual database name, username, and password) or connection. You are not importing the RequestSite from the correct spot.

Change (wherever you have this set) from:

from django.contrib.sites.models import RequestSite

to:

from django.contrib.sites.requests import RequestSite

0👍

This is documentation you should look at this for connecting to databases and how django does it, from what you gave us, as long as your parameters are correct you should be connecting to the database but a good confirmation of this would be the inspectdb tool.

https://docs.djangoproject.com/en/1.10/ref/databases/

This shows you how to import your models from the sql database:

https://docs.djangoproject.com/en/1.10/howto/legacy-databases/

To answer your question in the comments


Auto-generate the models

Django comes with a utility called inspectdb that can create models by introspecting an existing database. You can view the output by running this command:

python manage.py inspectdb

Save this as a file by using standard Unix output redirection:

python manage.py inspectdb > models.py

Leave a comment