install #django
install #django
Replies
python3 manage.py runserver
django-admin startproject mysite
python manage.py startapp appname
in terminal: `python3 -m pip install Django`This will install Django in the virtualenv you have active.Once done, to verify, type `python3` to enter the python shell and type:>>> import django>>> print(django.get_version())(without the >>>, those are automatically there on each line with python)You should see the the version # in the terminal below the commands
Confirm install:`python3 -m django --version`
After having set up a "polls" app in our "djangoTest" project, and created models in our polls app, you have to activate those models in the project by first adding polls to INSTALLED_APPS setting of djangoTest and then running a `python3 manage.py makemigrations polls` command
make migrations file for "polls" app folder model changes that when migrated will add those new models or model changes to database
Shows what SQL code a specific migration file will run
polls = the app folder, 0001 = the specific migration file
Playing around with the api
Full database api documentation
creates a python date entity using datetime.datetime module format. Can be converted to desired format by calling strftime() on the element created with a format string passed in, see https://www.w3schools.com/python/python_datetime.aspfor list of format codes
python manage.py test polls
in desired virtual envpip install psychopg2but ran into some issues. To solve:brew install openssl (if not already installed)and in the virtual envexport LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/https://stackoverflow.com/questions/59065263/is-there-any-problem-installing-psycopg2-in-virtualenv-on-macos-catalina-with-pohttps://github.com/psycopg/psycopg2/issues/997
startup postgres serverpostgres -D /usr/local/var/postgres
www.link.com
https://knovigator.com/quest/django-custom-commands-6m2x4z3g