
Django 2.1 released - parvenu74
https://docs.djangoproject.com/en/2.1/releases/2.1/
======
jtchang
For anyone thinking about picking up Django and is worried about the framework
being obsolete I encourage you to take a look.

Django is fantastic. I've worked with it for a number of years now and it can
really help in the early stages of prototyping.

Things I especially like about Django:

* The built in admin letting you edit and view objects easily.

* Being able to use it without using the views. Add django rest framework and you can model your domain with good REST practices.

* Migrations and works well with postgres.

* That the team has thought a lot about web security and how to implement it. Things like XSS, CSRF, CORS, session timeouts, authentication are all there in Django. Other frameworks I need to pull in a library for each and pray that they work well together. I found this especially with Flask and large projects it gets ridiculous how much I have to write from scratch.

Things that would make me not choose Django:

* If you have a graph style problem and need a graph database like neo4j. (Even then I'd probably want some part relational)

* If you accept lock in to someone else's platform like firebase and don't want to run your own servers.

* raw speed is an issue and you are okay with development taking much longer. In that case you're looking at some of the golang frameworks and possibly node/express.

~~~
borplk
A huge reason some people consider frameworks like Django obsolete is because
they are focused on an older web paradigm of constructing elaborate html pages
on the server side and pushing it out and letting some basic extra js stuff
augment it.

That's what lead to things like server side HTML form definition and form
handling code.

After the emergence of things like React, Angular, etc those "html templating"
facilities get in the way because that stuff is baked into the react app and
is focused on the client side, it may get server side rendered with nodejs. A
modern fancy web application using React in 2018 doesn't need something like
Django forms or Flask-WTF and those types of things conflict and overlap with
things like React.

The backend is turning more into a data/API/GraphQL service than "get html"
service that was popular when these frameworks emerged.

~~~
andybak
> an older web paradigm of constructing elaborate html pages on the server
> side and pushing it out and letting some basic extra js stuff augment it.

Sounds like an awesome idea.

> That's what lead to things like server side HTML form definition and form
> handling code.

You make these sound like bad things.

> those types of things conflict and overlap with things like React

So why presume the thing to abandon isn't React for many use cases?

> The backend is turning more into a data/API/GraphQL service than "get html"
> service that was popular when these frameworks emerged.

Which is fine if you're building a complex web app but stop encouraging people
to build content sites this way. It's a terrible idea and they usually have
deep UX flaws due to incomplete attempts to rebuild functionality that you get
for free if you stop reinventing the wheel.

50% of the sites I visit seem to break some subtle aspect of bookmarking,
navigation, caching, reloading or something else that they have no business
messing with.

~~~
KyeRussell
The world needs more people like you. Thank you.

I have a very varied workload which includes both complex web applications and
content driven sites (very basic, accomplishable-by-WordPress marketing
sites). I had a client move their very basic portfolio + blog site to a new
developer who rewrote it from scratch. The new site has a loading / splash
page before the _real_ site displays. It's entirely JS driven and ticks all
the boxes for bad implementation (badly implemented fake links, no use of the
history API, bad accessibility.etc).

I don't see how this is not a step backwards. Nothing was gained here except
for some resume-driven development. Frankly, it strikes me as something that
inexperienced developers do because they aren't aware of a world outside of
React (or at the very least consider it to be obsolete).

~~~
gkya
What we have is basically worse than flash. At least nothing serious except
video was strictly dependent on Flash.

------
fredley
I've been working with Django for almost my whole career, since 1.1. It's a
joy to use, and blows any other web framework I've used out of the water when
it comes to actually just building stuff.

Django is a fantastic boring[1] tool, and seeing boring updates like this is
great.

1: [http://mcfunley.com/choose-boring-technology](http://mcfunley.com/choose-
boring-technology)

~~~
zimablue
As a counter point, I tried to use Django for a data-visualisation project and
ran into some problems. Everything is built on models, which are kind of
activerecord pattern. Django has an inbuilt (and inferior) version of
sqlalchemy, so that when you want to push sql past a certain point (define
queries more complex than the api) you're pretty much stuck. Now you have
codebase with two different database libraries in it. You're probably using an
spa so all the view stuff isn't helping, and Django kind of infects your code
because it won't run without an initializarltion step so if you have a module
importing something that imports Django, any time you use that it needs to
initialize Django itself. I don't think that these are mistakes, just choices
that they made that make it very good for websites up to a certain (sql/data)
complexity and very annoying afterwards.

~~~
akx
The Django ORM has raw SQL escape hatches (either fully raw SQL database
connections or model instance selections with SQL), and if you do need the
SQLAlchemy query builder, slap in something like
[https://github.com/Deepwalker/aldjemy](https://github.com/Deepwalker/aldjemy)
.

As for the initialization stuff -- yes, that's true; whenever Django models
are being imported, you do need to have had `django.setup()` called.

~~~
zimablue
yea good point, I should have mentioned the raw SQL escape hatch, that also
isn't an ideal solution. I went for aldjemy/instead them and in retrospect
starting with something sqlalchemy native would have been cleaner.

~~~
c0un7d0wn
We went the other way around and came up with
[https://github.com/shosca/django-rest-
witchcraft](https://github.com/shosca/django-rest-witchcraft) and
[https://github.com/shosca/django-sorcery](https://github.com/shosca/django-
sorcery) to integrate sqlalchemy with django as the project was already using
sqlalchemy.

------
appleiigs
A reminder to support these guys! 24% funded and they’re only asking for
$200K. :(

[https://www.djangoproject.com/fundraising/](https://www.djangoproject.com/fundraising/)

~~~
Alir3z4
Thanks for mentioning. I was going to post that I see you did it already.

Such a heavy mega framework that small to big companies and individual relies
on, we should support it.

Whoever sees this, please support Django to reach its goal.

------
blorenz
Congrats Django team! This iteration doesn't add too much for my current
workings with the framework but it matures it none-the-less. My usual project
compositions utilize Django, GraphQL, and React. I'm earnestly watching
[https://www.aeracode.org/2018/06/04/django-async-
roadmap/](https://www.aeracode.org/2018/06/04/django-async-roadmap/) to
hopefully work it's way into the near future releases.

------
theptip
Read-only model views are a great addition to the Django admin -- I've been
watching that PR for a long time, glad to see it land.

This will make it a lot easier to build internal admin dashboards that are
safe to share with non-privileged users like support staff.

~~~
keshab
I have seen a bastardized version of Django admin used as a quite
sophisticated dashboard. This new addition will make it even easier to hack
together things like that in a very short time.

~~~
paganel
One of my first Django projects was to “bastardize” its admin into a
Lead/Opportunity management system for a mortgage broker, back in the version
0.96 days. I know that monkey-patching is now frowned upon and reguarded as
“the work of the devil” but it really helped me get the job done for that
project in a pretty reasonable amount of time. I hope dynamic programming
makes a come-back.

------
dopeboy
I work with a lot of clients and for every project, it's Django. I love how
readable the code is. I've even had non-technical clients peer into the code
and make correct observations.

And it's been said already, but Django Admin is a crown jewel. I can't tell
you how many clients have jumped with delight when they realize they get that
functionality out of the box. It ends up turning into a great admin dashboard
and pseudo analytics tool---atleast for the short term.

If you're jumping on the GraphQL train, I'd encourage you to check out
Graphene. It's a Django library that serves as a GraphQL provider. Reasonably
well documented and production ready, IMO. If you're looking a Django +
GraphQL + React starter project, mbrochh's project [0] is a good place to
start. It is slightly outdated but the core patterns are still reusable.

[0] - [https://github.com/mbrochh/django-graphql-apollo-react-
demo](https://github.com/mbrochh/django-graphql-apollo-react-demo)

------
paulhallett
Django is the only web framework where I see consistently positive discussions
about it on HN.

Bravo Django, and congratulations on another release!

~~~
parvenu74
This aspect has me looking at getting into Django; what have the discussions
on HN regarding ASP.NET Core (the new open-source stuff) been like? I'm mainly
in pre-Core MVC and looking to move up to something I can deploy to any
Docker-hosting environment.

~~~
undseg
I can't help you with ASP.NET Core, as I have no experience building and/or
deploying it.

What I can chime in with though is: In my days as a web dev I started off and
learned the ropes with ASP.NET (MVC was recently coming up), and after moving
to django for another project I felt right at home.

It's very impressive how the django project was able to rival a behemot like
Microsoft in terms of usability, reasonable defaults and developer
convenience, overall design, documentation, upgradability.

The REST stuff (django rest framework) and some aspects of managing models
were actually quite ahead of ASP.NET at the time for getting you up to speed
with things.

Of course the tech stack around them is completely different and something
you'll want to think about, but in terms of features and how things are laid
out you don't need to worry, django has you covered.

------
collinmanderson
Release notes here:
[https://docs.djangoproject.com/en/2.1/releases/2.1/](https://docs.djangoproject.com/en/2.1/releases/2.1/)

------
brightball
Are there any good reads on Django for former Rails devs? I'm learning Django
now and interested for the "translation".

~~~
richjdsmith
I am the same. Not because I want to stop using Rails (I <3 Rails), but rather
just to increase my repertoire. Let me know if you find something!

------
lowercased
Open question re: django:

[https://docs.djangoproject.com/en/2.1/ref/models/fields/#nul...](https://docs.djangoproject.com/en/2.1/ref/models/fields/#null)

I've got a colleague who has been using django for a couple of years (and has
15+ years experience with python outside of web, as well as java, php, arduino
hacking, 3d printing, etc).

He pointed me to the link above re: nulls - I can't figure out why the default
would be to convert a null to an empty string. All major databases can
understand nulls just fine.

"... If a string-based field has null=True, that means it has two possible
values for “no data”: NULL, and the empty string. In most cases, it’s
redundant to have two possible values for “no data;”..."

An empty string is "no user supplied data" and a null is "no value has been
given at all". It seems rather ... odd(?) to try to conflate the two.

Am I missing something?

I've got perhaps a slight bias against django, in that the only people I've
known who've used it were either junior devs who had no experience in anything
else (and raved about it), or senior folks who've inherited a relative django
mess (usually the result of the aforementioned junior devs).

~~~
caspar
> An empty string is "no user supplied data" and a null is "no value has been
> given at all"

I assume you meant "an empty string is user supplied an empty string as data".

That aside, you wouldn't normally switch that option on for a field (notice
the default is false).

However, Oracle DB stores empty strings as indistinguishable from NULLs[0], so
an ORM supporting Oracle DB may want to have some support for converting
"empty or null" to an empty string at read time (notice the Oracle specific
caveat in the docs in your link).

Once you have that, I'd guess the thinking is that you may as well let devs
opt into that behavior (bear in mind that sometimes you're in the position of
developing a new app against an existing db, that may or may not have another
legacy app reading/writing from it at the same time).

0: [https://stackoverflow.com/questions/203493/why-does-
oracle-9...](https://stackoverflow.com/questions/203493/why-does-
oracle-9i-treat-an-empty-string-as-null/203536#203536)

~~~
lowercased
> I assume you meant "an empty string is user supplied an empty string as
> data".

I think so - it was a bit late. But it's the diff between intentional empty
value and unknown/initial value.

I still don't grok why django seems to want, by default, to ignore the concept
of storing "null" in the database, and makes you jump to non-default
configuration to do something which has value (seeing nulls vs empty strings
means different things).

------
trevor-e
Can anyone recommend a framework like Django except for a static language? I
tried Django and really liked what I saw, but I can't see myself using Python
for a large project.

~~~
collinmanderson
There's been some work to add type-hinting to Django if that helps.

Check out:

[https://github.com/TypedDjango/django-stubs#django-
stubs](https://github.com/TypedDjango/django-stubs#django-stubs)

[https://gitter.im/mypy-django/Lobby](https://gitter.im/mypy-django/Lobby)

------
oneweekwonder
To django model users. Can you query keys inside a JSON datatype(pgsql)[0]
from the ORM?

For example in sqla you will do:

    
    
        records = db_session.query(Resource).filter(
                   Resources.data["lastname"].astext == "Doe"
               ).all()
    

with data being the json column and lastname a key in the column.

[0]:
[https://stackoverflow.com/a/29975187](https://stackoverflow.com/a/29975187)

~~~
kennydude
Django's version of that query (to me) looks a little neater too.

    
    
        records = Resource.objects.filter(
                   data__lastname__exact="Doe"
               )

~~~
oneweekwonder
One can also write the sqla query as:

    
    
        Resource.query.filter(
            Resources.data["lastname"].astext=="Doe"
        )
    

Personally I find the "__" convension strange and not sure that it would be
obvious to new comers that you are accessing a key in the data column.

------
StavrosK
Fantastic work! After the last few feature-packed releases, I'm happy to see a
bugfix one. Upgrading should be a breeze.

~~~
Alex3917
After running my test suite, I'm seeing zero deprecation warnings (let alone
failures) in 2.1. I'll still wait a couple months before upgrading in
production, but this should be one of the easiest upgrades in a long time.

