Architectural Pattern of DRF

595 views
Skip to first unread message

Alex G Rothberg

unread,
Jan 21, 2015, 10:35:45 AM1/21/15
to django-res...@googlegroups.com
What (if any) is the best architectural pattern to describe DRF? Is it MVC, MVVM, 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

Jani Tiainen

unread,
Jan 22, 2015, 5:03:28 AM1/22/15
to django-res...@googlegroups.com
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)
Alex G Rothberg <agrot...@gmail.com> wrote:

> What (if any) is the best architectural pattern to describe DRF? Is
> it MVC, MVVM <https://en.wikipedia.org/wiki/Model_View_ViewModel>, or
> --
> 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-fram...@googlegroups.com. For more options,
> visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages