Those snippets were taken from utkik's docs and are probably part of a larger code; but I agree they probably belong somewhere else, maybe in a middleware.
BTW, thanks for the nice post. Is the code available on github or bitbucket?
https://github.com/brack3t/django-braces is the Github repo, or you can ``pip install django-braces`` into your project. All the mixins are then imported from the ``braces`` package.
The decorator actually raises an interesting issue. Are permissions and security part of the core application logic, or are they wrappers.
The mixin approach is nice and OO, but it's potentially tying two different layers of functionality together. Whereas the decorator is closer to aspect-oriented programming which attempts to isolate core business logic from such modifiers.
I'm actually quite interested in the challenge of applying design patterns for large systems (inversion-of-control, AOP etc) to Django, which has some stubborn behaviours that get in the way.
Django's documentation is indeed terrible for class based views, but I encourage any developers that have had trouble reading through it to just take a look at the source. I found it to be much easier to learn that way.
I agree. Reading the source is so 2000s. Part of why Django has enjoyed it's community growth is because of it's culture of documentation. And for Django to have released something that isn't well documented is untypical.
This isn't a complaint, except at me. I've promised to update those docs for coming up on a whole year. :P
15 comments
[ 3.4 ms ] story [ 36.3 ms ] threadA few months ago I started using a small class-based views library called aino-utkik[1] and haven't looked back.
Instead of this:
I can write this: which I find way more elegant.[1] https://github.com/aino/aino-utkik
And, yes, our mixins are Django-only (hence the title!)
Also, why the ``set_test_cookie`` on every GET?
BTW, thanks for the nice post. Is the code available on github or bitbucket?
https://github.com/brack3t/django-braces is the Github repo, or you can ``pip install django-braces`` into your project. All the mixins are then imported from the ``braces`` package.
The mixin approach is nice and OO, but it's potentially tying two different layers of functionality together. Whereas the decorator is closer to aspect-oriented programming which attempts to isolate core business logic from such modifiers.
I'm actually quite interested in the challenge of applying design patterns for large systems (inversion-of-control, AOP etc) to Django, which has some stubborn behaviours that get in the way.
I'll have to give it another look later, maybe I'll change my mind.
That's similar to expecting people to read the source code to understand ActiveRecord or something.
This isn't a complaint, except at me. I've promised to update those docs for coming up on a whole year. :P
Here it is, although the code is somewhat mixed with the old, function based, generic views: https://github.com/django/django/tree/master/django/views/ge...
https://github.com/AndrewIngram/django-extra-views