
Effective Django - equilibrium
http://effectivedjango.com/
======
po
I'd recommend a section on 'Function Based Views' in there as well. I've
personally found the CBV-based approach is sometimes good but in most cases I
still prefer the FBV approach. You see it often enough that I think it is
worth going over in detail.

~~~
mumphster
Is there any reason to still use them though? You could always just define a
`get`, `post`, (etc etc) method and have pretty much the same effect of a
functional view but with the added niceness of what CBV's provide (mainly
inheriting some other view with a lot of boiler plate)

~~~
shabda
[http://lukeplant.me.uk/blog/posts/djangos-cbvs-were-a-
mistak...](http://lukeplant.me.uk/blog/posts/djangos-cbvs-were-a-mistake/)
[http://lukeplant.me.uk/blog/posts/class-based-views-and-
dry-...](http://lukeplant.me.uk/blog/posts/class-based-views-and-dry-ravioli/)

IMO, CBVs are good, but for many cases FBV are simpler to code and easier to
understand.

~~~
emperorcezar
Defining a get method on a class is just as simple and allows for future
expansion.

~~~
po
…future expansion that I will probably never use. And I disagree that it's
just as simple. I think that CBV's encourage me (and my team, because I'm not
working in a vacuum) to think about the problem all wrong. You may like
thinking of the problem that way but for me it's like trying to think of a
song while another song is playing. I usually think of Django views as a
function, not a method on a class.

Django's FBV's are far from perfect and I think they really could benefit from
some small changes to the way things are done, but I agree with the above
links that CBV's were a step in the wrong direction.

~~~
emperorcezar
I'll have to just disagree with you here. I don't find the following any more
difficult then a functional view

class MyView(View): def get(self): return stuff

It's one more line, and is much more explicit in what it handles.

------
phildini
If you want to see the video of the guy who wrote Effective Django giving it
as a tutorial, here you go: <http://pyvideo.org/video/1717/effective-django-0>

------
film42
This is wonderful! I feel like the django documentation, combined with 10,000
stack overflow questions is the wrong way to get started, and yet, that's how
it was for me. I will use this all the time for tips and pointers. Thanks!!

------
eterm
Fantastic so far, easy to follow.

I've come to a snag at "Writing a Test"
([http://effectivedjango.com/tutorial/models.html#writing-a-
te...](http://effectivedjango.com/tutorial/models.html#writing-a-test) )
though, it's not clear which file I should be adding the test class to.

From following the tutorial I would think models.py but from browsing the file
structure I would expect test.py

~~~
seagreen
I don't know if this is the absolute best way but Two Scoops of Django
recommends having a tests folder in each app. So tests for
example_app/views.py are placed in example_app/tests/views.py.

------
joelthelion
Looks fantastic! Is there a way to get the whole thing in ebook format?

~~~
nyergler
I just built an EPub version from Sphinx; you can find it at
<http://effectivedjango.com/epub/EffectiveDjango.epub>. There are links from
the front page to the EPub and PDF versions.

~~~
joelthelion
Thanks a lot!!!

------
seanlinehan
This is awesome. I haven't touched Django even though I develop in Python on a
daily basis... been meaning to but hadn't found a reason to. I've bookmarked
this for when I finally get the itch.

Btw, there are some weird formatting issues in the tutorial (underscores after
links?).

~~~
nyergler
It's possible those are bad link targets in the ReStructured Text source, I'll
take a look. Thanks for calling that out!

------
pmouzo
Not a single mention of AJAX.

~~~
iends
Why is this an issue with an article about writing effective django?

~~~
gojomo
Many web apps/services now use at least a little AJAX. Certain things in a
framework can make it easier. Some discussion of how AJAX techniques, up
through 'single-page apps', can use a DJango back-end would be nice. (Maybe
not absolutely necessary... but nice.)

~~~
mattdeboard
Return JSON. The end.

~~~
gojomo
Then, a bit of docs about the JSON apis to use, and caveats/gotchas in using
them with Django Models would be helpful. The popular Django extension
TastyPie could be discussed, as well as URL schemes compatible with common
client-side libraries.

Similarly, ways to mimic single-page-app URLs from the server side, for first-
load speed or SEO benefits, could be discussed.

~~~
mattdeboard
What is a JSON api? Anyway, your entire wish list is out of the scope of the
document. If you want to know how to build a hypermedia API (which I think is
what you meant by json api) what does that have to do with "effective Django"?
That would be "building effective hypermedia APIs using Django".

~~~
gojomo
A JSON API is the methods & options that are available for (de)serializing
your native Python or Django objects into useful JSON.

Perhaps there's a more narrow 'scope' defined for this project, but simply
from the title, it seems an 'effective' Django developer would appreciate
guidance for the best ways to do AJAXy things (including, especially, RESTy
web services for backing AJAXy front-ends).

------
jamie
The folks behind this project know Django really well - I've recommended this
to people a number of times.

------
jbaiter
This is awesome, I've been starting to get into Django over the last few
weekends, and this is a godsend!

------
kanja
This is nice, but I'd recommend two scoops of django over this.

~~~
packetslave
Two Scoops is solid, but it's also a $14 ebook, whereas Effective Django is
free. Not really apples to apples.

~~~
thatthatis
This frustrates me. Three hours of time to watch a video, if you charge $50/hr
means you spend $150 opportunity cost of time on the free version. Assuming
the time to consume both is equal, it gives an equivalent cost of $150 vs
$164, or put another way, the difference in cost is a rounding error.

It seems to me the only durable advantage to the free version is that if it
isn't working out you can abandon it after 15 minutes at a fraction of the
cost. If there were a credible way to sell knowledge products "satisfaction
guaranteed" I'd think that people would be a lot less sensitive to the
difference between free and $14.

------
jck
considering that I already know python, if I wanted to make a good looking
personal gtd type webapp, am I better off learning django or should I rather
learn node.js?

------
buf
I worked with Nathan (guy behind Effective Django) at Eventbrite for a few
years and highly recommend him as being a very informed python and django
expert.

