This will be an index to the python work, including expecially footnoting virtual environments



on trout


cd ~; source .venv/bin/activate .venv



Python on droplet

  • Into the development directory

    cd /var/www/html//var/www/html/coffeeShop3/testUpload

  • Establish local environment.

    source .venv/bin/activate

  • Run sample

    python chatupload.py



The Django Form class


At the heart of this system of components is Django’s Form class. In much the same way that a Django model describes the logical structure of an object, its behavior, and the way its parts are represented to us, a Form class describes a form and determines how it works and appears.
In a similar way that a model class’s fields map to database fields, a form class’s fields map to HTML form elements. (A ModelForm maps a model class’s fields to HTML form elements via a Form; this is what the Django admin is based upon.)
A form’s fields are themselves classes; they manage form data and perform validation when a form is submitted. A DateField and a FileField handle very different kinds of data and have to do different things with it.
A form field is represented to a user in the browser as an HTML “widget” - a piece of user interface machinery. Each field type has an appropriate default Widget class, but these can be overridden as required


Your project’s TEMPLATES setting describes how Django will load and render templates. The default settings file configures a DjangoTemplates backend whose APP_DIRS option is set to True. By convention DjangoTemplates looks for a “templates” subdirectory in each of the INSTALLED_APPS.



Dec 19, 2023

Work is at ~/pythonSrc, on the droplet.

Failure

After getting updated sqlite library on 'droplet', and all python source, to rebuild, got errors at begining of 'make altinstall', a second bunch at the end.

sudo LD_RUN_PATH=/usr/local/lib make altinstall
if test "no-framework" = "no-framework" ; then \
	/usr/bin/install -c python /usr/local/bin/python3.12; \
else \
	/usr/bin/install -c -s Mac/pythonw /usr/local/bin/python3.12; \
fi
if test "3.12" != "3.12"; then \
	if test -f /usr/local/bin/python3.12 -o -h /usr/local/bin/python3.12; \
	then rm -f /usr/local/bin/python3.12; \
	fi; \
	(cd /usr/local/bin; ln python3.12 python3.12); \
fi
if test "x" != "x" ; then \
	rm -f /usr/local/bin/python3.12-32; \
	lipo  \
		-output /usr/local/bin/python3.12-32 \
		/usr/local/bin/python3.12; \
fi
if test "x" != "x" ; then \
	rm -f /usr/local/bin/python3.12-intel64; \
	lipo  \
		-output /usr/local/bin/python3.12-intel64 \
		/usr/local/bin/python3.12; \
fi
# Install macOS debug information (if available)
if test -d "python.dSYM"; then \
	echo  /usr/local/bin/python3.12; \
	 /usr/local/bin/python3.12; \
fi
if test "no-framework" = "no-framework" ; then \
	if test -d "libpython3.12.a.dSYM"; then \
		echo  /usr/local/lib/libpython3.12.a; \
		 /usr/local/lib/libpython3.12.a; \
	fi \
else \
	if test -d "libpython3.12.a.dSYM"; then \
		echo  /libpython3.12.a; \
       /libpython3.12.a; \
	fi \
fi
The necessary bits to build these optional modules were not found:
_bz2                  _ctypes               _ctypes_test       
_curses               _curses_panel         _dbm               
_gdbm                 _hashlib              _lzma              
_ssl                  _tkinter              _uuid              
readline              zlib                                     
To find the necessary bits, look in configure.ac and config.log.

Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

Checked 111 modules (31 built-in, 65 shared, 1 n/a on linux-x86_64, 0 disabled, 14 missing, 0 failed on import)
Creating directory /usr/local/lib/python3.12
Creating directory /usr/local/lib/python3.12/asyncio


These errors came at the end of the run

/usr/bin/install -c -m 755 Modules/xxlimited_35.cpython-312-x86_64-linux-gnu.so /usr/local/lib/python3.12/lib-dynload/xxlimited_35.cpython-312-x86_64-linux-gnu.so
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.12.1
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Traceback (most recent call last):
  File "", line 518, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 566, in _get_data
  File "", line 521, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 6, in 
  File "", line 222, in run_module
  File "", line 148, in _get_module_details
  File "", line 112, in _get_module_details
  File "", line 137, in get_code
  File "", line 700, in _get_module_code
  File "", line 568, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Traceback (most recent call last):
  File "", line 198, in _run_module_as_main
  File "", line 88, in _run_code
  File "/home/donzeek/pythonSrc/Python-3.12.1/Lib/ensurepip/__main__.py", line 5, in 
    sys.exit(ensurepip._main())
             ^^^^^^^^^^^^^^^^^
  File "/home/donzeek/pythonSrc/Python-3.12.1/Lib/ensurepip/__init__.py", line 284, in _main
    return _bootstrap(
           ^^^^^^^^^^^
  In response to 
sudo LD_RUN_PATH=/usr/local/lib make altinstall

got this, at beginning of execution:File "/home/donzeek/pythonSrc/Python-3.12.1/Lib/ensurepip/__init__.py", line 200, in _bootstrap
    return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/donzeek/pythonSrc/Python-3.12.1/Lib/ensurepip/__init__.py", line 101, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/donzeek/pythonSrc/Python-3.12.1/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/donzeek/pythonSrc/Python-3.12.1/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmper2_zyyp/pip-23.2.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmper2_zyyp\', \'--root\', \'/\', \'--upgrade\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [altinstall] Error 1

Dec 18, 2023

  • Get version 31 of sqlite3 onto the droplet: downloaaded first to trout, then uploaded to droplet. All according to this page
  • Related to that, had to download Python source (to compile sqlite3 oibraries in), that according fo this Update guide, scroll down to "Upgrading SQLite on CentOS to 3.8.3 or Later"

    Progress to


Nov 4, 2023

Continuing to follow Django tutorial


What’s the difference between a project and an app? An app is a web application that does something – e.g., a blog system, a database of public records or a small poll app. A project is a collection of configuration and apps for a particular website. A project can contain multiple apps. An app can be in multiple projects.



Generating admin sites for your staff or clients to add, change, and delete content is tedious work that doesn’t require much creativity. For that reason, Django entirely automates creation of admin interfaces for models.


Django was written in a newsroom environment, with a very clear separation between “content publishers” and the “public” site. Site managers use the system to add news stories, events, sports scores, etc., and that content is displayed on the public site. Django solves the problem of creating a unified interface for site administrators to edit content.
The admin isn’t intended to be used by site visitors. It’s for site managers.

Nov 3, 2023

Still getting trout setup. Ready to tackle python to recieve uploaded files

Following Django tutorial

  • Django Tutorial
  • Tutorial code is at /Users/donzeek/Development/django/djangTutorial/ricochet

Restucture potential - new example

will work within new framework (git download available: ~/Dev/django/fromStaco/minimal-django-file-upload-example )


Nov 1, 2023

Still getting trout setup. Ready to tackle python to recieve uploaded files


May 8, 2023

  • pyenv activate django-venv
  • pip install Django==4.2.1
  • python3.11 -m pip install --upgrade pip
  • pip install requests
  • python

Workflow
  • source ~/.virtualenvs/djangodev/bin/activate
  • deactivate




March 16, 2023

Where to put all API keys for remote accounts. Piling up, previously posting something in the journal:

  • Created user 'aware' in user-group 'wheel' on AWS
    Access key ID
    AKIA3DLORG2H6M5YKRM3
    Secret access key
    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
    Sign-in URL for IAM users in this account
    https://763125380751.signin.aws.amazon.com/console

  • April 16, 2023

    Virtual Environments
    • ~/.virtualenvs/envApiConsumpt/
    • ~/.virtualenvs/temp/
    • ~/.virtualenvs/djangodev/
    • ~/.djdev0/
    • ~/Developer/docker/linkedIn/virtuenviro/
    • ~/Developer/Python3/gui/pySimpleGui/simpGuiEnv/
    • ~/Developer/ansible/project0/ansibleEnv/


    Workflow
    • source ~/.virtualenvs/djangodev/bin/activate
    • deactivate



    April 21, 2023

    Fished linkedin-learning tutorial at
    LinkedIn Learning. Exercise files are linked from that page.

    Steps to sketch together project:
    Start a Project

    $ django-admin startproject zcs_project

    creates subdirectory zcs_project, creates project framework there (including manage.py)

    Execute skeleton project

    $ python manage.py runserver

    initiates the included simple server, to read (or reread) program output and respond to client probes.

    Start an application within a project. Locate.

    $ cd <where manage.py is>

    This is where application level is modified.

    Create the app

    $ python manage.py startapp zcs_app_name

    This creates the application directory 'zcs_app_name' under the project directory 'zcs_project', and on the initial run creates db.sqlite3.

    Within directory 'zcs_app_name' are files:
    admin.py
    apps.py
    models.py
    tests.py
    views.py


    Register the application

    Go to the project directory, 'zcs_project', find the settings.py file, change it to add to the environment variable INSTALLED_APPS the string object 'zcs_app_name'.


    Update (or modify) the database schema

    Doing this is managed by migrations. To incorporate any unapplied migrations

    $ python manage.py makemmigrations


    To see migrations status

    $ python manage.py showmigrate


    To execute migrations

    $ python manage.py migrate


    April 22, 2023

    continuing with transcription

    Retrieve database tools from here

    Copy DSV data to a position sibling to manage.py

    Move 'Management' directory from exercise_files into same.

    Digest CSV data as follows:

    $ python manage.py load_pet_data

    'load_pet_data' is a method in parent/Management

    Inspect sqlite3.db using downloaded tool




    Create a django super user:

    $ python manage.py createsuperuser;

    $ python manage.py runserver;




    From the exercise_files, retrieve starter)_templates.html

    Add base.html in 'templates' alonngside home.html and pet_detail.html