Flashcard Deck · 22 cards · Public

Harvard CS50W - Web Programming with Python and JavaScript

Master full-stack web development with this high-yield flashcard deck for Harvard CS50W. Dive deep into Django ORM, RESTful APIs, JWT authentication, and asynchronous JavaScript for dynamic web applications.

Cards in this deck

(22 cards)

Preview terms and definitions before starting your study session.

#1
Term
What is the purpose of Django's ORM?
Definition
The Django Object-Relational Mapper (ORM) allows you to interact with your database using Python code, abstracting away raw SQL. It maps database tables to Python classes (models) and rows to objects, simplifying database operations.
#2
Term
How do you retrieve all objects from a Django model named Book?
Definition
You can retrieve all objects using Book.objects.all(). This returns a QuerySet containing all Book instances in the database.
#3
Term
Explain the difference between filter() and get() in Django ORM.
Definition
<ul><li>filter(): Returns a QuerySet containing objects that match the given lookup parameters. It can return zero, one, or multiple objects.</li><li>get(): Returns a single object matching the given lookup parameters. If no object or more than one object is found, it raises an exception (DoesNotExist or MultipleObjectsReturned, respectively).</li></ul>
#4
Term
How do you create a new record in a Django model Author with name='Jane Doe'?
Definition
You can create a new record using Author.objects.create(name='Jane Doe'). Alternatively, you can instantiate the model and then save it:
python2 lines
author = Author(name='Jane Doe')
author.save()
#5
Term
What are Django database migrations used for?
Definition
Migrations are Django's way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They are essentially Python files that describe these changes.
#6
Term
What is the command to create migration files for changes in your Django models, and what command applies those changes to the database?
Definition
<ul><li>To create migration files: python manage.py makemigrations</li><li>To apply migrations to the database: python manage.py migrate</li></ul>
#7
Term
List the six guiding principles of RESTful architecture.
Definition
<ol><li><b>Client-Server:</b> Separation of concerns.</li><li><b>Stateless:</b> Each request from client to server must contain all information needed to understand the request.</li><li><b>Cacheable:</b> Responses must explicitly or implicitly define themselves as cacheable or non-cacheable.</li><li><b>Uniform Interface:</b> Simplifies system architecture.</li><li><b>Layered System:</b> A client cannot ordinarily tell whether it is connected directly to the end server or to an intermediary.</li><li><b>Code-On-Demand (Optional):</b> Servers can temporarily extend or customize client functionality by transferring executable code.</li></ol>
#8
Term
In REST, what is a "resource" and how is it identified?
Definition
A resource is any information that can be named, such as a document, an image, or a service. In REST, resources are identified by Uniform Resource Identifiers (URIs), which are typically URLs.
Showing 8 of 22 cards in this deck.
Study All Now