Django Level Five Flashcards
which password hashers did we install?
argon2: pip install django[argon2]
bcrypt: pip install bcrypt
to use a password hasher, it must be added to the ____ in settings.py
PASSWORDS_HASHERS list

syntax for adding an option to a password validator
What is the difference between static files and media files?
content that you provide (static) versus content that your user provides (media)
code for setting up static and media directories.

what library must be installed in order to work with images?
the python imaging library:
pip install pillow
always remember to register models that you want admin control over to the ___
admin.py file
Broad steps for creating a UserProfileInfo() model
- import models and User
- define the class
- instatiate the user field which uses the imported User model as its base by way of the .OneToOneField() method
- add additional fields to the UserProfileInfo model
- def a string representation of the model

what does the on_delete=models.cascade mean as an argument in a OneToOneField() or ForeignKey()?
When the referenced model is deleted, also delete other model instances that referenced it.
what does the blank=true mean as an argument in a FieldClass?
Information for that field can remain blank
When using an ImageField() class, how does it know where the file should be stored?
add the kwarg: upload_to=’profile_pics’
List the broad steps for creating a Form class in forms.py
1. import forms, User, and UserProfileInfo from their respective sources
- define the class
- add any fields that are not already present in the model that we are creating a form for (this step can be skipped).
- define a class Meta() with model equal to the mode we are basing the form off of, and the fields from that model (and the form class) that we want to add to the form.

what is the code for adding a password input widget to a Form class?
what are the heirarchy of tags when creating a navbar?
- nav
- div
- ul
- li
- li
- li
- ul
- div
how do you change how each button in a navbar looks?
List the broad steps for creating a registration form in an html file (dont worry about styling).
- check if the user is registered
- If the user is not registered display the form using template tags and the csrf_token
- add a submit button
it may be good practice to place a form inside of what kind of div class value?
jumbotron
for the form tag, what should the two attributes be, what are they equal to, and what is their purpose?
enctype=”multipart/form-data”
- needed since we are uploading multimedia images
method=”POST”
- tells Django that submission of this form yields a post request.
List the broad steps for creating the register view function.
- import render from django.shortcuts and import the UserProfileInfoForm
- initialize the registered value to equal false
- with an if statement give instructions for the request being a “POST” which is to pull (instantiate) the data entered into the forms. if not a “POST” request, we will get back the empty forms.
- with a nest if statement check for validation of the instantiated forms. will print error reports if validation fails.
- save all the data entered into the form using the appropriate statements and flip registered to equal True
- return a render with the dictionary containing all the variables needed for the html file.

what does request.method == “POST” mean?
- The user submitted a form that they filled
- No we need to do something with the provided information
what method checks for the validity of a form?
.is_valid()
how do we hash and save the user password?
user.password ultimately comes from the password that we entered into the form.
why would we ever pass the kwarg commit=False into a save() method?
If we want to hold off on saving in the case that contradictions arise.
what is this line of code doing?
profile.user = user
it is establishing that OneToOne relationship referenced earlier in models.py
