
How to Tango with Django: A Python Django Tutorial - pajju
http://www.tangowithdjango.com/
======
leephillips
This looks like it might eventually become a useful resource, as there is
nothing else out there with its particular approach and combination of topics,
and it seems fundamentally sound.

However, I wouldn't recommend trying to learn from it in its current form,
unless you already know a lot.

Just skimming over it, I found that it was teeming with grammatical errors and
typos, with entire sentences garbled to the point where I couldn't tell what
the authors had intended to say. I saw syntax errors in the code samples,
which means that they weren't all verified to run as printed. Again, not a
real problem except for beginners, but beginners are the target audience.

Finally, there is some utility to the concept of _prerequisite_ that the
authors seem to avoid.

This book tries to teach the beginner everything that he might need to know,
from what "ls" does in the shell to how to use git and set up virtual
environments. Maybe it is practical to go from never having seen the command
line to deploying working, secure Django projects just by using a (cleaned up
version of) this book, but doesn't it make more sense to learn things in a
more solid progression of stages? It's OK to expect the student to already
know some basics, and build on those. You don't find a tutorial on arithmetic
in a book about topology.

~~~
huxley
Yeah but I think more beginner material should spell out the proper way of
doing things even if it is "unrelated". My pet peeve is beginner material that
reads something like:

"to make this example simpler, I am going to do something incredibly insecure.
In production you would never ever do this, but I'm still going to do it, so
if you are unfamiliar with foo, make sure you know all about bar too."

As well, if I was teaching someone Django/Python development from scratch
today, I would definitely include pip, virtualenv, and git/mercurial as part
of the baseline. HTML is a hypertext medium so you could let people who know
skip ahead.

~~~
smspence
"if I was teaching someone Django/Python development from scratch today, I
would definitely include pip, virtualenv, and git/mercurial as part of the
baseline."

They DO show you how to use pip, git, and virtualenv.

Check out the overview:
[http://www.tangowithdjango.com/book/chapters/overview.html#w...](http://www.tangowithdjango.com/book/chapters/overview.html#what-
you-will-learn)

One of the first things they explain is how to use pip:
[http://www.tangowithdjango.com/book/chapters/requirements.ht...](http://www.tangowithdjango.com/book/chapters/requirements.html#using-
setuptools-and-pip)

They also show how to get started with git:
[http://www.tangowithdjango.com/book/chapters/git.html#git-
cr...](http://www.tangowithdjango.com/book/chapters/git.html#git-crash-course)

and virtualenv:
[http://www.tangowithdjango.com/book/chapters/requirements.ht...](http://www.tangowithdjango.com/book/chapters/requirements.html#virtual-
environments)

edit: I actually think I might have misunderstood your comment. Sorry. Anyway,
just leaving this comment here for posterity.

------
rmrfrmrf
Question for Rails and Django users: is there a site that gives definitive
best practices for both? I've actually been thinking about building a thrown-
together site for just that purpose.

I've tried to get into _both_ Rails and Django twice now (I'm a PHP guy
usually), but every time I seem to get going, I get bogged down by
StackOverflow after StackOverflow that have seemingly contradictory
information or offer a third party solution rather than solving the problem
within the framework.

In Rails, for example, Rails is easy enough, until you're dealing with RVM * ,
Passenger * , and installing correct dev versions of database drivers.

In Django, you deal with South migrations when you want to update your
database schemas, virtualenv * , virtualenvwrapper * ; in fact, I've heard
that one of the criticisms of Django is that, in order to get to production
quality, you essentially have to switch out every component of it with a third
party.

* The starred apps don't technically have anything to do with the framework; they're more utilities for managing multiple framework instances. Still, you're likely to find tutorials that use them as a de facto standard, which only adds to noob confusion.

I've started reading Michael Hartl's Rails tutorial, which seems promising. I
found that the highly-recommended "Two Scoops of Django" book was a little too
narrative for me (just tell me what to do, dammit!); there's definitely a need
for more Django tutorials than just the Django website's basic one -- kudos to
the author for that.

~~~
tocomment
I'd say don't worry about south if you're not working with a big team.

Just track the changes you make to your models and make the same changes to
the database.

~~~
gardarh
I don't agree with that. I'd say don't worry about south if you're just
starting out playing with django and willing to manually delete tables every
now and then to get make sure your db matches your models.

As soon as you are doing something that anyone relies on and to save you
endless effort you should use South, IMO. Even if it's a one-person project (I
have a few of those) South saves you both a lot of time and aggravation.

~~~
frankwiles
Absolutely agree. Even something as simple as adding an optional field is just
./manage.py schemamigration --auto <appname> and you're done vs "ALTER TABLE
blah blah blah...." on your local system, dev/staging, and then again on
production in the right order, every time, manually. Can't imagine anyone
wanting to go back to manual after using South.

~~~
rmrfrmrf
This thread perfectly exemplifies the frustration laid out in my original
post.

~~~
jaegerpicker
Welcome to development with open source technology. It takes time and effort
to figure out the best practices. There is no magic bullet, sorry. That's not
meant to be snarky it's just the way the process works.

------
BenderV
For people starting with Web Framework or new to Python, I would suggest
starting with a lightweight framework, such as Flask or Pylons.

I used to struggle with Django, so I started to look into Flask, and I really
feel like I finally understood what I was doing.

Flask tuto : [http://flask.pocoo.org/](http://flask.pocoo.org/)

~~~
hadem
Would you have the same suggestion for seasoned web developers in other
languages, but who are still new to Python?

I'm curious as I'm really looking to learn Python and was looking at Django
for the web side of things.

~~~
metaphorm
Flask is inherently simpler/smaller than Django. For doing simple/small web
sites its a naturally good fit. However, due to its simplicity it needs to be
significantly augmented if you intend to build a more complex web app with it.

Augmenting Flask with a data persistence layer, a RESTful API system, a more
robust templating system, and any of the other infrastructure tools you'll
need (user auth, session management, xss protection, input
cleaning/validation, etc.) is quite complicated. If you go through those steps
you'll basically just end up with something like what Django gives you right
out of the box. Except that Django's components are well integrated with each
other and fully tested, and your custom built system won't be.

------
mladenkovacevic
This would've been immensely useful when starting out.

Official tutorials and docs don't cover nearly all of the accepted standard
practices. As a relative outsider it seems a lot of this Django/Python
knowledge is taken for granted by the tightly knit community of the skillful
developers who interact with each other and exchange various tips, while a
beginner who is not really embedded in the community misses out on all that
and picks it up only when it's widely enough used that it hits the blogs and
podcasts in bits and pieces.

------
brabram
From a quick overview I really like your approach: you start by a hello world
directly (then template, then models) instead of doing this strange approach
of the django official tutorial that starts with model then admin interface
then show an hello world at part 3. I also really like the presence of
exercices.

Quick comment: here, you are teaching render_to_response
[http://www.tangowithdjango.com/book/chapters/templates_stati...](http://www.tangowithdjango.com/book/chapters/templates_static.html#adding-
a-template) while you should be using render instead
[https://docs.djangoproject.com/en/1.5/topics/http/shortcuts/...](https://docs.djangoproject.com/en/1.5/topics/http/shortcuts/#django.shortcuts.render)
which is simplier than render_to_reponse (where you have to use the horrible
context_instance=RequestContext(request) to be able to do certain things in
the template which confuse a lot people).

Thanks for this contribution to the django community!

------
lahwf
Another awesome resource for Django Screencasts is Neckbeard Republic.

[https://www.neckbeardrepublic.com/tagged/django](https://www.neckbeardrepublic.com/tagged/django)

------
kmfrk
You should probably not use django-registration for user auth as referred to
in the guide, since it's been abandoned at this point:
[https://news.ycombinator.com/item?id=6278464](https://news.ycombinator.com/item?id=6278464).

~~~
leifos
Thanks for the tip. We hope to include a chapter that uses OpenAuth instead.
It is on our TODO list :-)

~~~
kmfrk
Cool. What made you go with OpenAuth?

I couldn't spot an issue discussing it, but if you have a good link on the
pros and cons, I'd love to see it. :)

~~~
leifos
We are still investigating the options, but OpenAuth seems like a pretty
useful open and applicable standard for authenticating users. In the book, we
are trying to build up a series of guides on useful tools and toolkits for
doing things.

So I'd also like to read about the pros and cons of the various authentication
packages.

------
amarsahinovic
Django screencasts for the interested:

[https://godjango.com/](https://godjango.com/)

[http://gettingstartedwithdjango.com/](http://gettingstartedwithdjango.com/)

~~~
lahwf
you should take a look at
[http://neckbeardrepublic.com/](http://neckbeardrepublic.com/) as well. one of
the pycoder's guys does it.

~~~
amarsahinovic
Looks interesting, thanks!

------
htaunay
Another great resource is
[http://gettingstartedwithdjango.com/](http://gettingstartedwithdjango.com/)

------
djd606
This is fantastic! Congrats and keep up the good work! Will there be an ebook
version available any time in the future? Thanks again.

~~~
leifos
Thanks! We appreciate your comments.

We'll be releasing a pdf and ebook in the future, but if you can't wait you
can download the source for the book from github, see
[http://bit.ly/1bVKKJf](http://bit.ly/1bVKKJf)

We've written the book in Python Sphinx so it is easy to compile into pdf.

------
hawkharris
I recently started to learn Ruby on Rails. I like the language and the
framework, but I also appreciate the simplicity and power of Python.

Which framework should I focus on if my priorities are professional
development and ease of workflow? I realize this is a hard question to answer,
but I'm interested in hearing different perspectives.

~~~
avenger123
I also was deciding between which language to learn and its corresponding web
framework. What's the criteria for you? For me, one of the main criteria's is
the applicability of the language and its supporting ecosystem across many
application domains (ie. web, scientific, systems programming, etc.).

I am not tied to either language (not yet at least) so the decision was based
more on "bang for the buck". I decided that Python is a better investment of
my time. This was largely based on the fact that Python is used in many, many
areas outside of web development. As a result, I feel python will server me
more across most domains versus Ruby. It's true that Ruby can also be used in
many different application domains but based on my research, it just doesn't
have the legs that Python has for general programming. For better or worse,
Ruby is widely known as "Ruby on Rails".

In terms of which language is better, both are good so this wasn't a factor.

~~~
hawkharris
Thanks for your insights. I share your priorities in terms of wanting to find
a language that's widely used for general programming as well as the web. I'll
have to spend more checking out Python!

------
erokar
Looks impressive. I'm a Ruby guy, but I would probably start with this if I
was getting into Python/Django.

------
STRiDEX
Looks good! The part I chose to jump to was deployment as there's a million
ways to do it and I've been looking for a best practices. Was a little
saddened to see you chose PythonAnywhere not because the service is bad, but
because it has a limited use case.

~~~
leifos
Yeah there are a million ways to deploy for simplicity we choose
PythonAnywhere. This was mainly because when you are teaching 200+ students,
you need it to be easy, quick, and free (also it doesn't require a credit card
to join).

We also hope to expand this chapter in the future to show how to migrate to a
real database.

If you have some suggestions about other platforms to deploy on we'd love to
hear them.

------
Siecje
Good Tutorial. I like how you are building a website and adding features.

So far I have made it to the Ajax page.

Why don't you use render in your views, and url tags with the name in urls.py?

Also there is a lot of typos. Is the site open source?

------
n1ghtm4n
Thank you for putting so much work into this, but it's not Python 3!

~~~
leifos
Totally! We hope to put another version out next summer using Python 3 and the
latest version of Django at that point.

------
orenbarzilai
Another recommended resource for learning Django:
[http://www.djangobook.com/en/2.0/index.html](http://www.djangobook.com/en/2.0/index.html)

~~~
frakkingcylons
Please don't recommend the Django book to people. It's very out of date (in
case you didn't read the warning on the front). Use the official Django
tutorial [1] instead.

[1]:
[https://docs.djangoproject.com/en/1.5/intro/tutorial01/](https://docs.djangoproject.com/en/1.5/intro/tutorial01/)

~~~
amarsahinovic
There are plans to update the book, but they need help with that:

[https://readthedocs.org/projects/django-book-
new/](https://readthedocs.org/projects/django-book-new/)

[https://github.com/jacobian/djangobook.com](https://github.com/jacobian/djangobook.com)

------
leifos
Thanks for all your comments and suggestions so far. Please keep the coming.

