Discussion:
Architectural Pattern of DRF
Alex G Rothberg
2015-01-21 15:35:45 UTC
Permalink
What (if any) is the best architectural pattern to describe DRF? Is it MVC,
MVVM <https://en.wikipedia.org/wiki/Model_View_ViewModel>, or some other
pattern?

In trying to describe how the various components (models, views, routers,
serializers and parsers/ renderers) of DRF map to the more traditional
roles of MVC, the best I came up with is:

DRF MVC
-------------------------
model M
serializer+renderer V
router + view C

In the case of DRF, the DRF/Django "view" looks at the header, etc to
determine the Rendering / Parsing needed. The render+the serializer does
the actual "view" part of MVC. That being said, MVVM might be a more
accurate architecture.

the flow looks like:

Model --(Serializer)--> python dict/list --(Renderer)--> json/xml/yaml/html

or

Model <--(Serializer)-- python dict/list --(Parser)<-- json/xml/yaml/html
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jani Tiainen
2015-01-22 10:03:23 UTC
Permalink
REST itself is an architectural pattern.

Trying to figure out sematics to map MVC to any client-server
technology will eventually fail since MVC is designed to work with
desktop GUI applications - mainly to separate UI part from the other
logic.

And even if you could figure out something it's better not to try to
reinvent terminology - Django itself has concept of a view already
which is not equal to MVC view part.

Same appliest to DRF - it has rather solid architecture that doesn't
fit any other than REST terminology. So what ever you try to figure out
it's best to describe components as they are, models are models,
serializers are serializers and so on. Also note that you may have
models that are in database but how about models that are not?

Trying to hammer all that to something else will eventually just cause
a confusion with terms.

On Wed, 21 Jan 2015 07:35:45 -0800 (PST)
Post by Alex G Rothberg
What (if any) is the best architectural pattern to describe DRF? Is
it MVC, MVVM <https://en.wikipedia.org/wiki/Model_View_ViewModel>, or
some other pattern?
In trying to describe how the various components (models, views,
routers, serializers and parsers/ renderers) of DRF map to the more
DRF MVC
-------------------------
model M
serializer+renderer V
router + view C
In the case of DRF, the DRF/Django "view" looks at the header, etc to
determine the Rendering / Parsing needed. The render+the serializer
does the actual "view" part of MVC. That being said, MVVM might be a
more accurate architecture.
Model --(Serializer)--> python dict/list --(Renderer)-->
json/xml/yaml/html
or
Model <--(Serializer)-- python dict/list --(Parser)<--
json/xml/yaml/html
--
You received this message because you are subscribed to the Google
Groups "Django REST framework" group. To unsubscribe from this group
and stop receiving emails from it, send an email to
visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...