Django Level Two Flashcards
what do we use o tie a database to a Django Project?
Models
What backend engine comes with django? is the only one you can use?
SQLite
no
Each attribute of a Model class represents a …
field
SQL operates like a …
giant table
What is a field constraint?
an argument passed into a field method that limits something.
Tables can reference each other using the concepts of ___ and ___.
Foreign Keys and Primary Keys.
__: a unique identifier for each row in a table
Primary Key
___: denotes that the column coincides with a primary key of another table.
Foreign Key
The migrate command:
python manage.py migrate
command to register migrations changes to the app?
python manage.py makemigrations app1
What must we do to interact with models using the admin interface?
We must register them to the app’s admin.py file

A ___ needs to be created to be able to use the Admin features.
superuser
Command for creating a superuser.
python manage.py createsuperuser
The name of the model(class) is synonymous to the name of …
the data-table to be created.
every model (class) inherits from …
the Django base class models.Model
Every attribute aka field, must have its field type specified by …
instantiating it using django’s built in field classes
A constraint of the charfield that limits the amount of characters that can be inserted into the Topic model.
max_length
a kwarg constraint the limits the presence of duplicates.
unique=true
What args get passed into a ForeignKey method?
- The name of the model that it is connected to
- what to do in the case that the associated Model gets deleted.
should you always include a string representation of every model you create?
YES
What package did we learn to use to populate models with fake data? how do we install this package?
Faker
Pip install Faker
List the high level steps for population your website with fake data using Faker.
- configure the project settings to allow for models to be manipulated
- import and set django up
- import all the functions and models needed
- import Faker and instatiate it
- create functions that add data that you generated
- create a function that uses the instatiated Faker object to create however much fake data
- use if __name__ == ‘__main__’ to tell the script when to run

What would be the syntax for creating a fake object using faker?
what does the function .get_or_create() do? what are its args?
.get_or_create() will retrieve the field if it already exists in the model, and if not it will create it.
it is composed of an arbitrary number of kwargs, matching the models field object with the instance of fake data that was generated for that field.