Django Design Patterns

40 views
Skip to first unread message

Fatjon Gërra

unread,
Nov 17, 2019, 10:25:33 AM11/17/19
to Django users
Hi guys, can anyone suggest me some resources book/video/article where I can learn more about Design Patterns that the Django Team used in writing Django as a framework? For example, here the Active Record pattern is mentioned. I am looking for the other ones. I want to dive into Django's source code and learn about Design Patterns at the same time. Thanks for the help!

Antje Kazimiers

unread,
Nov 17, 2019, 7:40:33 PM11/17/19
to django...@googlegroups.com, Fatjon Gërra

Hi Fatjon,

I wonder how much you can try finding that out on your own by just grepping for the names of the common Gang of Four [1] - design patterns in the django source code. I just tried Observer, Factory and find examples in the code, which sound like the developer really followed the intention of that pattern, when they named the function / class, which is good. Another example is Decorator:

> git grep decorator

gives many results, among those the file

django/utils/functional.py

There are the lines of code

def keep_lazy(*resultclasses):
    """
    A decorator that allows a function to be called with one or more lazy
    arguments. If none of the args are lazy, the function is evaluated
    immediately, otherwise a __proxy__ is returned that will evaluate the
    function when needed.
    """
    if not resultclasses:
        raise TypeError("You must pass at least one argument to keep_lazy().")

    def decorator(func):
        ..
    return decorator

and that to me really looks exactly what the purpose of a decorator is.

Antje

[1] https://en.wikipedia.org/wiki/Gang_of_Four


On 11/17/19 3:40 AM, Fatjon Gërra wrote:
Hi guys, can anyone suggest me some resources book/video/article where I can learn more about Design Patterns that the Django Team used in writing Django as a framework? For example, here the Active Record pattern is mentioned. I am looking for the other ones. I want to dive into Django's source code and learn about Design Patterns at the same time. Thanks for the help!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/039a922c-a882-4e82-be0b-0ea568850074%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages