0% found this document useful (0 votes)
16 views1 page

Django 2

Django REST allows creating REST APIs from Django models and includes generic views, ORM mapping, signals, model methods, and model meta options. DRF provides ViewSets, pagination, filtering, and browsable API rendering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Django 2

Django REST allows creating REST APIs from Django models and includes generic views, ORM mapping, signals, model methods, and model meta options. DRF provides ViewSets, pagination, filtering, and browsable API rendering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Django REST

- generic views - for example ListCreateAPIView

ORM = Object Relational Mapping

m2m_changed signal

Model instance methods

refresh_from_db()

>>> obj = MyModel.objects.first()


>>> del obj.field
>>> obj.field # Loads the field from the database

clean(), full_clean() - latter also checks for uniqueness constraint

Model Meta constraints


- UniqueConstraint, CheckConstraint

Meta options
- abstract
- managed (defaults to true) - tells Django to manage the database tables’
lifecycles; when set to False, Django won't create a DB table, etc.; useful when
the model represents an existing table created by other means
- ordering - the default ordering of the object

Proxy models
- useful in multi-table inheritance, where we don't want the child model to have
it's own table
- a proxy model can have e.g. a different ordering, so that you can query the same
table in two different orders, depending on which model you invoke

Differences between proxy inheritance and unmanaged models¶


1. If you are mirroring an existing model or database table and don’t want all the
original database table columns, use Meta.managed=False. That option is normally
useful for modeling database views and tables not under the control of Django.
2. If you are wanting to change the Python-only behavior of a model, but keep all
the same fields as in the original, use Meta.proxy=True. This sets things up so
that the proxy model is an exact copy of the storage structure of the original
model when data is saved.

DRF:
A Viewset groups multiple related actions together, handles different HTTP methods,
and often leverages automatic URL routing using routers.

Cursor pagination - only forward and backward controls

Filtering backend

Browsable API

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy