Learning Django: Approach / Advice / Resources

35 views
Skip to first unread message

Robin

unread,
May 30, 2011, 3:30:24 PM5/30/11
to Django users
A little while ago, I was approached about building a basic web site
for a small store. The requirements were pretty typical and read like
a menu of web development tutorials. This was to be a data driven
site that any decent web developer could build. I, however, am not a
web developer, decent or otherwise. So, I turned the assignment down
and decided it's time I looked into learning something about web
development.

I looked at everything from ASP to Java to PHP and even the likes of
Drupal and Joomla. I liked the ideas and patterns behind Django as a
framework ( MVC = :) ) and Python as a language. The combination
seemed like perfect middle ground to me. Things were going well as I
worked through the tutorial and explored the documentation to dig
deeper into core Django topics. Where am I today?

I'm struggling a bit with Django, to be honest. Or maybe I'm
struggling with Python, I'm not completely certain which. Maybe it's
because I'm trying to learn web development and Python at the same
time. I'm certainly no genius, but I'm not a bonehead either...at
least my mother doesn't think so. ;)

The individual technical ideas are presented well and I can always
find enough information to learn more. But Django as a whole feels
less cohesive. Or maybe it's that Django sometimes feels...TOO
flexible? There are certainly a lot of choices in terms of how much
Django to use and how much to roll yourself. Guidance seems to be
offered on a per-module basis. Maybe that's just how it is and I'm
looking for structure where there is none available.

I'm not sure what to override...when to call the super classes
corresponding method. Do I have to concern myself with the test
cookie idea? Should I name my URLs? Is mixing positional and keyword
arguments OK? Are generic views the best way, or just the quickest
way?

I guess it boils down to a concern over making poor choices and
learning bad habits. If I'm going to spend any amount of time with
this web development hing, I want to do it right. I'm also fighting
my urge to build everything myself. Sure it would be plenty flexible,
but it would also take longer and wouldn't leverage the great work
done by all of Django's contributors.

So, what am I rattling on about then?

Judging by some of the posts I've read since joining the group, I'm
sure there are a bunch of folks who would appreciate some guidance
and / or best practices from the more experienced Django developers.
I understand everyone learns and progresses differently, but I would
really appreciate your take on things.

How much do you use built in Django functionality? Are there
components you tend to avoid? Do you use Django only for certain
types of projects? Do you struggle with Python or Django? Is the
source code a good place to spend some time? Is your authentication
system home-grown? Have you been bitten in the behind by using too
much Django? Not enough?

I realize this is a lot to ask, but I think it's a good thing that we
help newer developers do things the right way. I certainyl want to
become a contributing member of this group, but not until I won't give
bad advice and flat out wrong answers. ;)

I've gone through a good chunk of the Django Book online. Is this a
good resource or do you have other recommendations? There aren't all
that many books on Django, but there are a few. Do any do a better
job than the others of guiding you to the best way to build web
sites / apps? I sure wish there was a book that kept pace with the
changes and the miost recent version. Is the fact that there isn't
much available a bad sign?

Just jump in and adjust as I learn my lessons?

Regards,

Robin

Mike Dewhirst

unread,
May 30, 2011, 7:15:05 PM5/30/11
to django...@googlegroups.com
Robin

Don't worry - your mother is probably right.

Here are my "rules" ...

1. Dive into Python 3 rocks

2. Read "Practical Django Projects"(*) or if you decide against that get
yourself a small-ish concrete target and avoid extraneous functionality
like the plague. Then when it is working look for other people's open
source django apps to plug in and widen the scope with more functionality.

This is the core of my suggestion. If you keep your own portion of your
next website really tiny and as simple as necessary it will be much
easier to refactor for more elegance and better performance in future.
Adopting this approach forces you to learn how everyone else does it.

I think your problem is that you want to achieve too much at once. The
more experience you get the narrower the focus your apps have. The less
each does the better. That takes courage and practice and makes unit
testing much easier.

I also believe the django core team are arguing a false benefit for
django - flexibility. Sure you can do it any way you like but that is no
help for beginners. It only scores points off rails people and they
aren't coming to django in numbers which could ever match beginners
choosing between rails and django.

Flexibility is a later benefit absolutely essential when you run into a
brick wall and is one of the main reasons experienced developers choose
django.

The real genius of django is a system which lets heaps of applications
collaborate in a single website.

* James Bennett - but don't even think of downloading his example code.
Write your own as you read along.

My 2 cents

Mike

Derek

unread,
May 31, 2011, 10:07:31 AM5/31/11
to Django users
Hi Robin

Not sure I can address all your issues, so I will just pick up on a
few...

One thing from the start -> " If I'm going to spend any amount of time
with this web development thing, I want to do it right." You will -
eventually. Its often really hard to do it right first time because
you do not have enough experience to know if you're making a mistake!
Getting going, doing stuff and maybe putting out in public the parts
you are most concerned/unsure about is the best way to get the
experience...

"struggling with Python"

I cannot say that its essential to know Python in depth before
starting web programming, but I would say it would be a huge help.

Its not clear what programming experience you have. If none, then its
worth starting with the basics of programming. If you have some, then
try and find a comparison between the language you used and Python
(pref. written by a Python person).

Some useful "getting started" tutorials:
* http://docs.activestate.com/activepython/2.5/easytut/index.html
* http://www.gidnetwork.com/b-26.html

After reading and trying out what someone else has done, try and build
stand-alone stuff in Python. A simple use case is accessing and
processing Excel spreadsheets using xlwt and xlrd. If you ever have
to do any data processing for third-parties, you're almost bound to
use/re-use what you have done here. Otherwise think of a common need
from the area you work in.

"struggling with Django"

Django is meant to be comprehensive. That's good if you want to be
able to do anything, but bad if you're just getting started. If I
showed my old self from 2 years ago the code that I have written
today, I'd be overwhelmed, no doubt. Learning programming is
incremental and experiential. You learn code by writing; and improve
code by writing more. Remember (and this is easy to forget!!) that
the entire source code of Django is open to you... take some time and
read some of it - Python is designed to be a readable language. If
its too overwhelming, then try and look at the code of some of the
apps that are out there (and there are lots!). You'll see an entire
"module" and start to get some idea of how it all hangs together.
Then try it yourself; maybe start with something already there and
make changes to it until it breaks - try and figure out why - fix it -
and keep going. Use the same basic concepts to try and build
something new-ish yourself from scratch. As you go along and get
really stuck, post questions to the list (and please check first in
the archives - many people experience similar problems).

Q&A

Q: How much do you use built in Django functionality?
A: All the time!

Q: Are there components you tend to avoid?
A: None that come to mind; but I just use the ones I really need
("learn as you go").

Q: Do you use Django only for certain types of projects?
A: Its my primary web development framework; in my situation there is
no need to use multiple ones (and probably not a good idea when you're
just starting)

Q: Do you struggle with Python or Django?
A: Often - but that is when I *know* that I am learning

Q: Is the source code a good place to spend some time?
A: See above.

Q: Is your authentication system home-grown?
A: Nope; using 'auth' works for me

Q: Have you been bitten in the behind by using too much Django?
A: Not so far...

Q: I sure wish there was a book that kept pace with the changes and
the most recent version. Is the fact that there isn't much available
a bad sign?
A: Depends if you think the publishing industry is keeping up with the
web programming industry ;) I think you'll have to get one of the
committers to answer that; but to be honest I would rather they fixed
bugs and added features than wrote books (my 2c). In the meantime,
the online docs are readable, comprehensive and up-to-date. Django
has one of the most well-documented codebase of any open source
project.


Hope some of this helps - welcome to the community!

Derek

P.S. "Do I have to concern myself with the test cookie idea? I have
no idea what this is... please enlighten me!

Robin

unread,
May 31, 2011, 12:07:44 PM5/31/11
to Django users
You guys are spectacular! Thanks! I'll give these replies a few
reads and just keep plugging along. I'm going to sort of circle back
and see if it wouldn't be a good idea to restart my project with a
fresh set of eyes now that I've spent a bit of time with Django.

Derek,

The test cookie thing is -- as I understand it -- you place a test
cookie, then check if it's there. It's basically a check to see if
the browser accepts cookies. I'm just not entirely sure when I should
and shouldn't make the check when using parts of the built-in auth
moduel. I guess if I'm using the login view, it's will test for me.
I sort of started with the whole auth system, then backed out of using
the form and the view just to learn how it works on a basic level.
And in browsing the code, I saw the test cookie functions and did some
research.

Thanks again!

Robin
> *http://www.gidnetwork.com/b-26.html
Reply all
Reply to author
Forward
0 new messages