Python Forum
Question about dot notation syntax (Django source)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about dot notation syntax (Django source)
#3
From inside my Django project directory, I invoked:
$ locate password_validation
/home/tranq/cel2fah/venv/lib/python3.4/site-packages/django/contrib/auth/password_validation.py
/home/tranq/cel2fah/venv/lib/python3.4/site-packages/django/contrib/auth/__pycache__/password_validation.cpython-34.pyc
/usr/local/lib/python3.4/dist-packages/django/contrib/auth/password_validation.py
/usr/local/lib/python3.4/dist-packages/django/contrib/auth/__pycache__/password_validation.cpython-34.pyc
$
The first and second lines of outputs are my Django project directories inside my virtual environment and the third and fourth lines of output are my distribution directories in my native machine.

I’ve noticed a pattern. It appears that when a Django script (settings.py for example) is run and the libraries are imported at the top of the script (or in the case when the AUTH_PASSWORD_VALIDATORS variable is declared) it looks inside site-packages (inside my virtual environment) for the django directory, then for the auth directory which contains the password_validation.py module. settings.py refers to four classes inside the password_validation script:
  • UserAttributeSimilarityValidator
  • MinimumLengthValidator
  • CommonPasswordValidator
  • NumericPasswordValidator
Therefore, here is the direct answer to my question which I initially asked:

This string: django.contrib.auth.password_validation.UserAttributeSimilarityValidator in pseudocode, the pattern would reflect this:
‘DjangoDirectory.ContribDirectory.AuthDirectory.ThisModule.ThisClass’.

Then the methods (there are multiple) within that Class can be called and manipulated inside settings.py at runtime, like when the server is actively running servicing client requests.

In your case, @knackwurstbagel, your venv is located not inside your Django project directory but inside /usr/local/ which is better practices because it is more secure. I’ll look into it.

Thank you, Thank you, @knackwurstbagel for your helpful advice and for nudging me in the right direction rather than giving me the answer outright.
Reply


Messages In This Thread
RE: Question about dot notation syntax (Django source) - by Drone4four - Feb-16-2018, 07:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,461 Jun-30-2019, 12:21 AM
Last Post: scidam
  Python requests.get() returns broken source code instead of expected source code? FatalPythonError 3 3,794 Sep-21-2018, 02:46 PM
Last Post: nilamo
  Django syntax mepyyeti 2 2,567 Feb-16-2018, 05:03 AM
Last Post: Drone4four
  Django question tony1812 1 3,371 Aug-28-2017, 01:13 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020