/wiki/django-rest-frameworkEst: [2022/01/06 09:49:56]
A way to serialize model instances into representations. The process of making a streamable representation of the data which we can transfer over the network.
Serializer calsses can also include reusable validators that are applied to the complete set of field data. These validators are included by declaring them on an inner Meta class.
Is the reverse process for serialization. Allows parsed data to be converted back into complex types after first validating the incoming data.
When deserializing data, you always ineed to call is_valid() before attempting to access the validated data, or save an object instance.
.errors property will contain a dictionary representing the resulting error messages.
Each key in the dictionary will be a field name, and the values will be lists of strings of any error message corresponding to that field.
This key may also be present, and will list any general validation errors.
When deserializing an list of items, errors will be returned as a list of dictionaries representing each of the derserialized items.
Token authentication refers to exchanging username and password for a token that will be used in all subsequent requests so to identify the user on the server side.
HTTP Basic Authentication. Good for testing.
You cannot change the AUTH_USER_MODEL setting during the lifetime of a project (i.e. once you have made and migrated models that depend on it) without serious effort. It is intended to be set at the project start, and the model it refers to must be available in the first migration of the app that it lives in. See Substituting a custom User model for more details.
When you define a foreign key or many-to-many relations to the user model, you should specify the custom model using the AUTH_USER_MODEL setting. For example:
A Manager is the interface through which database query operations are provided to Django models. At least one Manager exists for every model.
The way maanger lcsses work is documented in Making Queries
It's a signal dispatcher that helpes decoupled applications get notified when actions occur elsewhere in the framework.
Signals allow certain senders to notify a set of receivers that some action has taken place.
To receive a signal, register a receiver function. The receiver function is called when the signal is sent.
An entry point into the logging system. Each logger is a named bucket to which messages can be written for processing.
A logger is configured to have a log level. Debug, Info, Warning, ect.
Each message is written to the logger as a Log Record. Each log record also has a log level indicating the severity of that specific message.
A log record can also contain useful metadat that describes the event that is bieng logged. It can include a stacktrace.
The engine that determines what happens to each message in a logger. It describes a particular logging behavior such as writing am essage to the screen, to a file, or to a network socket.
Like loggers, handlers also have a log level. If the log level doesn't meet or exceed the level of the handler, it will be ignored.
A logger can have multiple handlers, and each handler can have diffeerent log elvel. In this way, it's possible to provide different forms of notification.
Provide additional control over which log records are passed from a logger to handler.
By default, any log message that meets log level requirements will be handled. However, by instaling a filter you can place additiona criteria on the logging process.
Ultimately a log record needs to be rendered as text. Formatters describe the exact format of that text.
Python's logging library provides several technicuqes to configure logging.
In order to configure logging. you use LOGGING to define a dictionary of logging settings. These settings describe the loggers, handlers, filters, and formatters that you want in your logging setup, the log levels and other properties we want those components to have.
By default, LOGGING setting is merged with Django's default logging config.