On 16/07/2020 3:11 pm, Kshitij Kotasthane wrote: > If you could provide give a copy of the run-local.sh, that'd be great.
I don't have time to convert it into a bash script ... but you should be able to pick a minimum section of it and get your own bash script going. I started small and kept adding to it. Double-colon in a batch file is a comment and a single colon starts a label. Set sets an environment variable for the duration of the session. Here it is ... Good luck Mike - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @echo off echo . echo . echo . echo Should be running in virtualenv echo . echo . echo . echo . SET HOUR=%time:~0,2% SET dtStamp9=0%time:~1,1%:%time:~3,2%:%time:~6,2% SET dtStamp24=%time:~0,2%:%time:~3,2%:%time:~6,2% if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%) set proj=train set app1=common set port= :: run-local set test=mike-test set dev=mike-local set production=local set port=8999 :: run-staging ::set test=staging ::set dev=staging ::set production=staging :: run-prd ::set test=production ::set dev=production ::set production=production set testdata=%app1%\fixtures\test_data.json set initdata=%app1%\fixtures\initial_data.json if %2xx==xx ( set apps=%app1% billing course credit ) else ( set apps=%2 ) :: run if %1xx==xx ( set settings=%proj%.settings.%dev% echo on echo ... %settings% ... echo off python manage.py runserver %port% --settings=%proj%.settings.%dev% goto end ) else ( goto %1 ) :: End of args beginning of commands :check set tempcheck=production echo . echo checking security settings with %proj%.settings.%tempcheck% echo = = = = = = = See security.txt = = = = = = = = echo . python manage.py check --deploy --settings=%proj%.settings.%tempcheck% goto end :: - - - - - - - - - - - - - - end check :collectstatic python manage.py collectstatic --settings=%proj%.settings.%production% --verbosity=2 goto end :: - - - - - - - - - - - - - - end collectstatic :coverage coverage run manage.py test --settings=%proj%.settings.%test% --verbosity=1 %apps% echo %apps% coverage html --omit="*/Lib/*","*/tests/*","*/migrations/*","manage.py" goto end :: - - - - - - - - - - - - - - end coverage :dumpdata echo . echo dumping data (less --excludes) to %testdata% echo . python manage.py dumpdata --settings=%proj%.settings.%production% --indent=2 --verbosity=0 --natural-primary --natural-foreign --all --exclude=contenttypes --exclude=auth.permission --exclude=admin.logentry --exclude=sessions.session --exclude=billing.client --exclude=billing.relationship --exclude=billing.share --exclude=billing.price --exclude=billing.token --exclude=billing.receipt --exclude=billing.split --exclude=common.user --exclude=common.user_courses --exclude=common.user_course_note --exclude=common.userprofile --exclude=course.answer --exclude=course.course --exclude=course.instruction --exclude=course.question --exclude=credit.credit > %testdata% copy %testdata% %initdata% /Y goto end :: - - - - - - - - - - - - - - end dumpdata :fake echo . echo faking migration with %proj%.settings.%dev% echo . python manage.py migrate --fake --settings=%proj%.settings.%dev% %apps% %3 goto end :: - - - - - - - - - - - - - - end fake :makeemptymigrations :makempty python manage.py makemigrations --empty --settings=%proj%.settings.%dev% %apps% goto end :: - - - - - - - - - - - - - - end makeempty :makemigrations python manage.py makemigrations --settings=%proj%.settings.%dev% %apps% goto end :: - - - - - - - - - - - - - - end makemigrations :migrate echo . echo migrating with %proj%.settings.%dev% if not %3xx==xx echo migration name is %3 echo . echo . if %2xx==xx ( python manage.py migrate --settings=%proj%.settings.%dev% ) else ( python manage.py migrate --settings=%proj%.settings.%dev% %apps% %3 ) goto remove :: - - - - - - - - - - - - - - end migrate :remove_stale_contenttypes :remove python manage.py remove_stale_contenttypes --settings=%proj%.settings.%production% --verbosity=2 goto end :: - - - - - - - - - - - - - - end remove_stale_contenttypes :shell python manage.py shell --settings=%proj%.settings.%dev% goto end :: - - - - - - - - - - - - - - end shell :squashmigrations :squash echo . echo squashing migrations with %proj%.settings.%dev% for echo %apps% echo . python manage.py squashmigrations --settings=%proj%.settings.%dev% %apps% %3 goto end :: - - - - - - - - - - - - - - end squash :startapp python manage.py startapp --settings=%proj%.settings.%dev% %apps% goto end :: - - - - - - - - - - - - - - end startapp :test echo python manage.py test --settings=%proj%.settings.%test% --verbosity=1 echo %apps% python manage.py test --settings=%proj%.settings.%test% --parallel --verbosity=1 %apps% goto end :: - - - - - - - - - - - - - - end testing :testfail :failfast :fail python manage.py test --settings=%proj%.settings.%test% --failfast --verbosity=1 %apps% goto end :: - - - - - - - - - - - - - - end testfail :wall python -Wall manage.py test --settings=%proj%.settings.%test% --verbosity=1 %apps% goto end :: - - - - - - - - - - - - - - end wall :warn python -Wall manage.py runserver --settings=%proj%.settings.%dev% goto end :: - - - - - - - - - - - - - - end warn :end echo . echo Started: %dtStamp% SET HOUR=%time:~0,2% SET dtStamp9=0%time:~1,1%:%time:~3,2%:%time:~6,2% SET dtStamp24=%time:~0,2%:%time:~3,2%:%time:~6,2% if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%) ECHO Finished: %dtStamp% set json=%app1%\fixtures\initial_data.json if exist %json% (del %json%) goto bitterend if %1==check ( goto %1 ) if %1==collectstatic ( goto collectstatic ) if %1==coverage ( goto testcov ) if %1==dumpdata ( goto dumpdata ) if %1==fake ( goto fake ) if %1==makeemptymigrations ( :: leave apps as is goto makeemptymigrations ) if %1==makemigrations ( :: leave apps as is goto makemigrations ) if %1==migrate ( if %2xx==xx ( set apps= ) else ( set apps=%2 ) goto migrate ) if %1==map_csv ( goto map_csv ) if %1==ozone ( goto ozone ) if %1==remove_stale ( goto remove_stale_contenttypes ) if %1==shell ( goto shell ) if %1==squashmigrations ( goto squashmigrations ) if %1==startapp ( goto startapp ) if %1==test ( goto testing ) if %1==test-pg ( set test=mike-test-pg goto testing ) if %1==testfail ( goto testfail ) if %1==wall ( goto wall ) :bitterend - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > On Friday, 10 July 2020 07:13:12 UTC+5:30, Mike Dewhirst wrote: > > On 10/07/2020 12:11 am, Kshitij Kotasthane wrote: > > Doing this every time I run the server is really inconveninent as I > > said above. > > > > On Thursday, 9 July 2020 00:40:54 UTC+5:30, Luciano Martins wrote: > > > > python manage.py runserver localhost:5000 > > > > Em quarta-feira, 8 de julho de 2020 12:56:58 UTC-3, Kshitij > > Kotasthane escreveu: > > > > I recently started using django and because port 8000 on > my PC > > was already occupied, I had to modify the runserver.py file > > directly to start on another port. By default, shouldn't > there > > be an option in manage.py or settings.py to modify the > port to > > start the test server on? Or am I missing something? > > > > Because this is very inconvenient as well, > > > > | > > python manage.py runserver 5000 > > | > > > > Because I develop on Windows and also hate typing I wrote a batch > file > to launch manage.py with the correct settings. > > I call it run-local.bat > > It has a whole mess of vars at the top and I can edit those to > make it > work for different projects. I also use it for most of the manage.py > commands like ... > > run-local test > run-local coverage > run-local makemigrations > > Depending on what I'm doing it uses different settings files. For > example, tests with SQLite versus PostgreSQL. > > I even used it recently to run a series of psql commands to adjust > the > database when retrofitting one project with a custom user. That was > delightful because I could repeatedly reload the production database > locally and eventually got the migration perfect prior to saving > run-local.bat as run-prd.bat changing the database setting vars and > migrating the production database. I was very pleased with that. > > I also run Ubuntu machines and if I was developing on Linux or Mac > I'm > sure I could build a run-local.sh script there. > > If you (or anyone) would like a copy of my run-local.bat just ask > > Cheers > > Mike > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Django users" group. > > To unsubscribe from this group and stop receiving emails from > it, send > > an email to django...@googlegroups.com <javascript:> > > <mailto:django-users+unsubscr...@googlegroups.com <javascript:>>. > > To view this discussion on the web visit > > > > https://groups.google.com/d/msgid/django-users/d9acdb88-cb4b-496c-998d-0c48ac221b8do%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/d9acdb88-cb4b-496c-998d-0c48ac221b8do%40googlegroups.com> > > > > > <https://groups.google.com/d/msgid/django-users/d9acdb88-cb4b-496c-998d-0c48ac221b8do%40googlegroups.com?utm_medium=email&utm_source=footer > > <https://groups.google.com/d/msgid/django-users/d9acdb88-cb4b-496c-998d-0c48ac221b8do%40googlegroups.com?utm_medium=email&utm_source=footer>>. > > > -- > You received this message because you are subscribed to the Google > Groups "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to django-users+unsubscr...@googlegroups.com > <mailto:django-users+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/0c741c66-3da5-4905-af57-5ebe27476c3co%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/0c741c66-3da5-4905-af57-5ebe27476c3co%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eeb8a8e0-7392-c4d5-8762-642f00743682%40dewhirst.com.au.
signature.asc
Description: OpenPGP digital signature