simonw / django-sql-dashboard

Django app for building dashboards using raw SQL queries
https://django-sql-dashboard.datasette.io/
Apache License 2.0
437 stars 37 forks source link

Document how to use "test_project" for manual testing #120

Closed toolness closed 3 years ago

toolness commented 3 years ago

While working on #118, I wanted to run a Django project with the dashboard manually so I could make sure that everything looked and worked as expected.

The solution I landed on is a bit circuitous but it seemed to get the job done. First I created a test_project/config/settings_manual.py file with the following content:

from .settings import *

DATABASES["dashboard"] = DATABASES["default"]

Then I made a file called .env that set some environment variables:

export DATABASE_URL=postgres://myuser:mypassword@localhost/django_sql_dashboard_test_project
export DJANGO_SETTINGS_MODULE=config.settings_manual

Then I could manually test out any changes by running source .env and then using manage.py to create a superuser, run the dev server, and so forth.

With a few more permanent changes to the test_project folder in the codebase though, I think that it might be possible to support this better as a development use-case. But at the same time, I also understand that the test_project folder may never have been intended to actually be used manually... in any case, if you think this is a valid use of the test project, I could try submitting a PR and/or documentation that makes it a bit easier.

simonw commented 3 years ago

Yes, the test_project folder exists purely so I can get pytest to work.

You're right: how to actually develop against this is something that should be covered in the contributing docs.

I do it by having another Django project that I'm working on, then in that project's virtual environment I switch to the django-sql-dashboard folder and run pip install -e . - I should document this pattern!

simonw commented 3 years ago

That said, I think tour suggestion to make changes to test_project to support using it for development like this is a good one. Would definitely appreciate a PR that does this.

toolness commented 3 years ago

Ok cool! Er, would you also accept PRs that add Docker Compose setups (e.g. a docker-compose.yml and possibly a Dockerfile)? I like using it for working on projects without having to worry about setting up its dependencies, and I think it could be especially useful for working with test_project manually, but I also understand if you'd rather keep this free of docker things.

simonw commented 3 years ago

Closed by e82f8a6e6a75d01f61fc1cb2a8796c71efca75eb