
Learn web development: Django Web Framework - farabove
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django
======
StavrosK
This looks fantastic! May I suggest some syntax highlighting so the code boxes
don't look so drab, though?

------
nicolaslem
Django is such an important building block of the web, it completely deserves
this tutorial on MDN.

As someone who came to Django quite late, I cannot stress enough how coding in
Django is refreshing. Yes it's not about microservices nor it bring all the
trendy technologies that we all hear about.

And that's just fine, you get things done with it and at the end of the day
this is what matters.

------
desdiv
Dumb question, why does the guide suggest that you create an empty folder and
then initialize the project from there? (django_test/mytestsite,
locallibrary/locallibrary)

As far as I can tell, no file, hidden or otherwise, is left in the outer
folder.

~~~
benwad
I'm not sure if they do this in the tutorial, but it's a convention that some
people use to have the virtual environment next to the project folder in that
parent folder so that you don't have to gitignore it (just have the repo in
the project folder).

------
TheOneTrueKyle
Oh man, this is far superior to the official Django tutorial I think. MDN
really does a good job at holding your hand through the process.

There are moments when going through docs where way too many assumptions are
made about what I know. This is where prerequisites and objectives really help
out. I know what I am getting into before grokking.

~~~
soapdog
They also released a similar one about NodeJS + Express at
[https://developer.mozilla.org/en-US/docs/Learn/Server-
side/E...](https://developer.mozilla.org/en-US/docs/Learn/Server-
side/Express_Nodejs) both are very good at hand holding and helping you out.

The learning sites from MDN are very good. ;-)

------
idiotclock
Huh. Makes me miss php

~~~
farabove
Could you please elaborate on why it makes you miss PHP?

------
cponeill
This is pretty fantastic. I was just thinking about diving into learning
Django for an idea I want to build so this link is timely.

~~~
farabove
Best Django tut I have seen

------
icn2
Is Django restful in current version? Or I still need these if request.GET and
if request.POST ?

~~~
haikuginger
So, there are a few ways to handle it. DRF gives you a REST-oriented paradigm
to work with, but in standard Django, you can do class-based views with either
get, post, etc methods, or you can use generics like "ListView" and just
provide some stock methods like get_queryset to flesh it out.

------
gt565k
I had used Django back in version 1.3 and was just thinking today of how I
need to brush up, as it has been a few years.

The timing of this article couldn't have been better. Now I've got my weekend
cut out :)

~~~
legostormtroopr
Everything about Django 1.8 and above blows everything below away. Its all the
same, but so much better. The admin app keeps getting better, migrations are a
first class citizen and make ongoing change management and deployment a snap.

If you want to make a solid, stable web-app Django is a perfect backend.

~~~
metachris
This is so true. Point in case - Instagram also runs on Django!

------
voycey
It has been years since I have used Django - do they still expect everything
in the model to go in a single file or can you put each model in it's own file
now?

~~~
nicolaslem
Create a models.py and import there your models from wherever they are. This
should do the trick.

~~~
anewhnaccount
Yeah, or another way of splitting up huge models files is to convert models
from a module to a package by making a directory models and adding
models/__init__.py, models/foo_models.py, models/bar_models.py then doing

from .foo_models import *

from .bar_models import *

in your __init__.py

~~~
ageofwant
Separating models like this is a hint that you may need another app. It has
happened numerous times with me now that my models.py gets large and unwieldy,
I spends a hour breaking it all out and then I realise my one big God app
needs to be 3 smaller ones.

~~~
farabove
Totally agreed.

------
molly0
Great to see Mozilla supporting Django. But isn't the official Django tutorial
cover all of this, Why not just link to it?

~~~
vivekd
Django's basic tutorial is great to get started, but once you get into the
nitty gritty I find myself often going to stacks rather than the docs to get
the information I need because the docs get kinda sparse.

One example is if you want to forgo modelforms and pass the information from
the forms to the model manually through your view (for example because you
want to manipulate the information before passing it to the database). I
couldn't find anything in the tutorial that gave clear instructions on this
and had to go to stacks to find an example. Maybe the solution is simple and
obvious for most experienced programmers, but ordinarily the django tutorial
explains things clearly so even newbees like me can get into it so it was
disappointing that this was not done in this instance.

Another example is sessions, here is the sessions in the official django docs
-

[https://docs.djangoproject.com/en/1.10/topics/http/sessions/](https://docs.djangoproject.com/en/1.10/topics/http/sessions/)

it's great on how to configure and set up sessions, but as soon as you get to
how you use sessions in views it gets vague, confusing and way too sparse for
what its trying to explain. I didn't know how to use sessions after reading
it.

~~~
Lxr
I think the Django docs are pretty comprehensive in the scheme of things.
Maybe not perfect but better than average in this space.

~~~
vivekd
I would definitely agree with that, the first we program I tried to work with
was PHP and I think I might have given up on programming altogether had I not
discovered django with it's much better documentation.

I appreciate what they have done and appreciate the time and effort the Django
team put into their documentation, but more is always better and I think other
independent contributions on how to use django are also needed, especially
since most of the published books you can find on how to use django are out of
date

------
nikisweeting
If you're curious about how to set up a modern JS frontend on top of Django, I
wrote up a tutorial recently. It might be helpful if you're debating between
trying a Single Page App approach or some other design:
[https://medium.com/@theSquashSH/reconciling-djangos-mvc-
temp...](https://medium.com/@theSquashSH/reconciling-djangos-mvc-templates-
with-react-components-3aa986cf510a)

~~~
dopeboy
And if you're going down the React + Redux + REST framework path and need a
boilerplate to start off on, I'd highly recommend Seedstars':
[https://github.com/Seedstars/django-react-redux-
base](https://github.com/Seedstars/django-react-redux-base)

~~~
markdown
Care to share why?

My apologies if you have street cred in the field, but I don't know you, so
have no reason to trust your recommendation. Please tell me what makes this
particular project better than any alternatives.

~~~
dopeboy
No street card to offer --- just a developer passing on some knowledge. I've
been using Django for the past two years and React + Redux for the past year.
I've scoured around for boilerplates and that's the one that worked for me the
best. YMMV

~~~
markdown
Thanks.

