diff --git a/README.md b/README.md index 61ba124..3e2972c 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,13 @@ This is a template for new django projects -- to standardize on some nice featur Notes about the install instructions... -- The install-instructions below assume a unix-like environment (ie Mac, Linux, or Windows Subsystem for Linux (WSL)). +- The install-instructions below assume: + - a unix-like environment (ie Mac, Linux, or Windows Subsystem for Linux (WSL)). + - you've installed `uv` ([link][uv_link]) + - For now, here's a link to an [older version][old] of the repo that uses `pip`-based setup instructions. When improvements are made to this repo, this link will be removed. - The install-instructions below reference `x_project_stuff`, `x_project`, and `x_app`. In all cases replace with the name of your project, like: `isbn_api_project_stuff`, `isbn_api_project`, and `isbn_api_app`. -- You'll also need to update, in the install-instructions, the path to the version of python you're using. Sensible suggestion: use the version of python used by the oldest server on which you'll be running the code. (Django 4.2x requires at least Python 3.8.) - The `update_project_and_app_references.py` script ([link](https://github.com/Brown-University-Library/django_template_42_project/blob/main/update_project_and_app_references.py)) deletes the cloned `.git` directory (in addition to its main purpose to rename the project). Why? So you don't accidentally start building away and commit to the template repo. After this installation, creating a new git repo is one of the first things you should do. -- When you run the `pip istall ...` command, you may get a message about upgrading pip, with instructions. That's always a good idea, but not necessary for this install. -- When you start the webapp via `runserver`, you'll get a message that there are migrations that need to be run, with instructions. You can go ahead and do that, or do it later (this is a one-time thing). +- When you start the webapp via `runserver`, you'll get a message that there are migrations that need to be run, with instructions. You can go ahead and do that, or do it later. ```bash ## setup directories @@ -27,23 +28,21 @@ $ mkdir ./DBs $ git clone https://github.com/Brown-University-Library/django_template_42_project.git ## update project-name (line below is a single long line; clarifying in case it wraps) -$ /path/to/python3 ./django_template_42_project/update_project_and_app_references.py --target_dir "./django_template_42_project/" --new_project_name "x_project" --new_app_name "x_app" +$ uv run --python 3.8 ./django_template_42_project/update_project_and_app_references.py --target_dir "./django_template_42_project/" --new_project_name "x_project" --new_app_name "x_app" ## setup the envar-settings $ cd ./x_project/ $ cp ./config/dotenv_example_file.txt ../.env -## setup the virtual-environment -$ /path/to/python3 -m venv ../venv -$ source ../venv/bin/activate -(venv) $ pip install pip-tools -(venv) $ pip-compile ./config/requirements/requirements_base.in -(venv) $ pip install -r ./config/requirements/requirements_base.txt -(venv) $ python ./manage.py runserver +## run the app +$ uv run ./manage.py runserver ``` That's it! +[uv_link]: +[old]: + --- # stuff to try @@ -61,7 +60,7 @@ That's it! - Try . Once you `git init`, `git add --all`, and `git commit -am "initial commit"`, it'll show the branch and commit -- super-handy for dev and prod confirmations. -- Try `(venv) $ python ./manage.py test`. There are two simple tests that should pass. (Requires venv to be sourced.) +- Try `$ uv run ./manage.py test`. There are two simple tests that should pass. - Check out the logs (`project_stuff/logs/`). The envar log-level is `DEBUG`, easily changed. On the servers that should be `INFO` or higher, and remember to rotate them, not via python's log-rotate -- but by the server's log-rotate. diff --git a/manage.py b/manage.py index eb34647..e52507b 100755 --- a/manage.py +++ b/manage.py @@ -17,6 +17,8 @@ import os import sys +import django # for the "in case you're curious about versions" code + def main(): """Run administrative tasks.""" @@ -33,4 +35,10 @@ def main(): if __name__ == '__main__': + ## in case you're curious about versions -- feel free to comment out + if os.environ.get('RUN_MAIN') != 'true': + major, minor, micro = sys.version_info[:3] + print(f'using python version, ``{major}.{minor}.{micro}``') + print(f'using django version, ``{django.get_version()}``') + main()