Package: manage-django-project
manage_django_projectHelper to develop Django projects:Easy bootstrap a virtual environment:Just get the sources and call./manage.pyOnlypython3-pipandpython3-venvpackage needed to bootstarpAlle Django manage commands useable as normal CLIandviacmd2shellcmd2shell with autocomplete of all existing manage commands and all optionsAuto switching Django settings betweenlocalandtestssettings.Helpful manage commands for developing:Included Django management commands:code_style- Check/Fix project code stylecoverage- Run tests with coverage and reportinstall- Just install the project as editable via pip (Useful if version has been changed)playwright- Call playwright CLIproject_info- Information about the current Django projectpublish- Build a new release and publish it to PyPirun_dev_server- Setup test project and run django developer serversafety- Run safety check against current requirements filesshell- Go into cmd2 shell with all registered Django manage commandstox- Run tests via toxupdate_req- Update project requirements via pip-toolsupdate_test_snapshot_files- Update all snapshot files (by remove and recreate all snapshot files)How to use itSome steps are needed to usemanage_django_projectin your project.Here a overview and below details:addmanage_django_projectto your dev dependenciesYou Django project should have separate settings forprod,localandtests(Last two ones are used bymanage_django_project)Add the bootstrapmanage.pyAdd a__main__.pywith theexecute_django_from_command_line()call.In yourpyproject.toml:Add the[manage_django_project]sectionAdd the__main__-file as[project.scripts]Add the name of your[project.scripts]into bootstrapmanage.pyAll examples below usedmanage_django_project_example. You have to rename this string/path to your Django package name.Full example is here:https://github.com/jedie/manage_django_project/tree/main/manage_django_project_exampleIf everything works as expected you can just call the./manage.pyfile and the magic happens ;)main.pyAdd a.../manage_django_project_example/__main__.pyfile, looks like:frommanage_django_project.manageimportexecute_django_from_command_linedefmain():"""entrypoint installed via pyproject.toml and [project.scripts] section.Must be set in ./manage.py and PROJECT_SHELL_SCRIPT"""execute_django_from_command_line()if__name__=='__main__':main()pyproject.toml[project.scripts]manage_django_project_example="manage_django_project_example.__main__:main"[manage_django_project]module_name="your_project_example"# Django settings used for all commands except test/coverage/tox:local_settings='your_project.settings.local'# Django settings used for test/coverage/tox commands:test_settings='your_project.settings.tests'./manage.pyAdd a copy ofmanage.pyfile to your project source root.Change onlymanage_django_project_examplein this line:PROJECT_SHELL_SCRIPT=BIN_PATH/'manage_django_project_example'Start hackingJust clone the project and start./manage.pyto bootstrap a virtual environment:# Install base requirements:~$sudoaptinstallpython3-pippython3-venv# Get the sources:~$gitclonehttps://github.com/jedie/manage_django_project.git
~$cdmanage_django_project/# Just call manage.py and the magic happen:~/manage_django_project$./manage.py# start local dev. web server:~/django-for-runners$./manage.pyrun_dev_server# run tests:~/django-for-runners$./manage.pytest# or with coverage~/django-for-runners$./manage.pycoverage# or via tox:~/django-for-runners$./manage.pytoxBackwards-incompatible changesv0.2.x -> v0.3.xThe config was moved out from__main__.pyintopyproject.tomlYou must add in yourpyproject.tomlthe following stuff:[manage_django_project]module_name="your_project_example"# Django settings used for all commands except test/coverage/tox:local_settings='your_project.settings.local'# Django settings used for test/coverage/tox commands:test_settings='your_project.settings.tests'Theconfigargument was remove fromexecute_django_from_command_line(), so your__main__.pymust look like:frommanage_django_project.manageimportexecute_django_from_command_linedefmain():execute_django_from_command_line()if__name__=='__main__':main()Make new releaseWe usecli-base-utilitiesto generate the history in this README.To make a new release, do this:Increase your project version numberRun tests to update the READMEcommit the changesCreate releasehistoryv0.7.22024-02-20 - Add '--strip-extras' to pip-compile and update requirementsv0.7.12024-01-18 - Use typeguard in tests2024-01-18 - update requirements2024-01-18 - manageprojects updates + set min. Python to 3.9v0.7.02023-12-19 - Apply manageprojects: Expand test matrix + update req. + skip Python 3.92023-12-19 - Setup django for unittests2023-12-16 - Bugfix code style2023-12-16 - Use update_readme_history & as git hook2023-11-07 - Update requirementsv0.6.42023-11-01 - update requirementsExpand older history entries ...v0.6.32023-11-01 - Update requirements2023-11-01 - Autogenerate history in README2023-11-01 - Bugfix subprocess timeout running manage commandsv0.6.22023-09-24 - Use tools fromhttps://github.com/jedie/cli-base-utilitiesv0.6.12023-09-24 - Erase coverage data always after test run2023-09-24 - Add manage command to interact with Playwright CLIv0.6.02023-09-24 - Remove outdated history from README2023-09-24 - Nicer call command info2023-09-24 - NEW command: update_test_snapshot_files2023-09-24 - Auto erase coverage data2023-09-24 - Update requirementsv0.5.22023-08-17 - Bugfix: manageprojects must be a normal dependenciesv0.5.12023-08-17 - Use print_version from cli_base2023-08-17 - Update requirements2023-08-17 - cookiecutter_directory = "managed-django-project"2023-08-17 - apply template updatesv0.5.02023-08-15 - Usehttps://github.com/jedie/cli-base-utilities2023-08-04 - Update requirementsv0.4.12023-04-08 - Use get_pyproject_toml from manageprojects and add summarize output to update_reqv0.4.02023-04-07 - tests against different Django versions2023-04-07 - Enhance "update_req" commandv0.3.02023-04-05 - Move from__main__.pyintopyproject.toml2023-04-05 - Bugfix tox run2023-04-05 - Update manage.py2023-04-05 - Delete README.md2023-04-05 - Small project updatesv0.2.22023-04-02 - fix code style2023-04-02 - apply manage projects update2023-04-02 - Ignore nondjango.core.management.base.BaseCommandbased commands2023-04-02 - Update requirementsv0.2.12023-03-16 - fix test2023-03-16 - Add "Included Django management commands" to README2023-03-16 - typo2023-03-16 - Set v0.2.12023-03-16 - Enhance docs2023-03-16 - Removeprod_settingsand addlocal_settings_commandstoManageConfig2023-03-16 - Add test for bootstrap manage.py calls2023-03-16 - fix coverage by activating --concurrency=multiprocessing2023-03-15 - fix CI2023-03-15 - "tox" command: exit "normal" on failed run2023-03-15 - Add tests for "safety" command2023-03-15 - Test "tox" command2023-03-15 - Add test for "run_dev_server" command2023-03-15 - test "project_info" command2023-03-15 - Test command "install"2023-03-15 - Test command "code_sytle"2023-03-15 - Code cleanup: Remove unused files2023-03-14 - +Test coverage2023-03-14 - Test "update_req"2023-03-14 - Add basic test for "update_req"2023-03-14 - Add DocTest to unittests2023-03-14 - Add test for shell2023-03-14 - Skip broken commands2023-03-14 - remove debug printv0.2.02023-03-13 - NEW: "./manage.py shell" cmd2 shell with all registered Django manage commandsv0.1.12023-03-13 - Usedistribution_namein publish callv0.1.02023-03-12 - Remove a existing '.coverage' before create a new one2023-03-12 - check settings2023-03-12 - Rename test settings and check the used settings in test2023-03-12 - Run tests with test settings, before publishing2023-03-12 - Update README.mdv0.0.12023-03-11 - init2023-03-11 - Initial commit