1

Trying to follow this tutorial: https://knivets.com/how-to-integrate-django-with-existing-database/

and this SO: Using existing database in Django

My settings.py databases setup:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    # existing db I wan't to add
    'articles': { 
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'articles.sqlite3'),

    }
}

It does detect and generates a model based on the table I'm interested in. I've added this model to models.py and

python manage.py dbshell --database=articles

does show the table and that it holds data. However, in Django /admin the table shows up but breaks when I try to add to it and none of the existing data appears. This is the error that it throws:

OperationalError at /admin/core/articles/

no such table: articles

I appreciate any help ya'll can offer here.

3
  • Do you not need to add --database=articles to the dbshell command? Commented Mar 28, 2020 at 18:58
  • Thanks, I missed that. I've updated the post to indicate that this indeed works as well but that the table still is throwing an error in the app. Commented Mar 28, 2020 at 19:04
  • 1
    You probably need to add a database router to tell django which database to use for that model docs.djangoproject.com/en/3.0/topics/db/multi-db/… Commented Mar 28, 2020 at 19:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.