top | item 17663030

Django 2.1 released

307 points| parvenu74 | 7 years ago |docs.djangoproject.com | reply

125 comments

order
[+] jtchang|7 years ago|reply
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|7 years ago|reply
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.

[+] OmarGonzalez|7 years ago|reply
Why would anyone consider it obsolete to begin with ?

If anything, I would consider someone making that statement miss informed

[+] cdnsteve|7 years ago|reply
Also very notable benefits:

* Ease of upgrading between versions. This is especially critical and important if you have long lived projects.

* Excellent documentation

* Healthy community, contributors and project is run really smoothly by the team

* Project is a foundation vs single point of failure ,aka main dev loses interest, comparative to other frameworks

[+] txcwpalpha|7 years ago|reply
Are there people going around saying that Django is obsolete? I've seen a lot of people argue against using Django in favor of RoR or Flask, but that's usually based on personal preference. I've never seen anyone say that it's "obsolete".
[+] 52-6F-62|7 years ago|reply
At work because I have lately needed to roll web server/api/admin/client apps (embellished CRUD situations with some other serverside processing to generate user output) and for those my go to for dev speed, platform speed, familiarity, and a few other concerns I generally go with Node/Express/TypeScript and it's great to work with.

However for my personal site I used Django to give it a shot. Once I wrapped my head around a couple of different paradigms it was quite nice to work with, though I probably haven't laid it out as well as I would a real product or tool. It was very easy to get a pretty basic blog set up.

My only gripe might be on the blog end— it was kind of a pain to find a halfway-current compatible text editor for that purpose. But that isn't the end of the world for my own site. And of course, that's not an issue with Django itself.

[+] swah|7 years ago|reply
Another point: websockets. Golang is pretty good and (they say) Django kinda sucks. Have you used Django channels?
[+] fredley|7 years ago|reply
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

[+] ergo14|7 years ago|reply
It is worth noting that Pyramid Web Framework is also awesome to use. I see it as a middle ground between Django and Flask. The scaffolds make some design decisions for project and you can pick from what you like the most. Pyramid allows for extensible applications and never gets in your way.

The most critical Python infrastructure (PyPi) is now built with it, if you haven't tried it give it a shot. It is one of most well thought out frameworks for python in my opinion.

I've made a tutorial for it: https://docs.pylonsproject.org/projects/pyramid-blogr/en/lat....

[+] OmarGonzalez|7 years ago|reply
Django is a fantastic boring[1] tool, and seeing boring updates like this is great.

couldn't agree more

[+] godzillabrennus|7 years ago|reply
My roommate in College built a site with 0.96 of Django. It’s still running.

I think it’s one of if not the longest running commercial Django websites.

[+] spacesarebetter|7 years ago|reply
I have been using symfony since the 2-3 years because the product is build on symfony. Now i like symfony, because i’m not a big fan of PHP. Anybody knows how Django compares to Symfony. I have glanced through Django documentation few times and it look a little similiar. If somebody has used both frameworks, what are the main advantages of Django over Symfony?
[+] zimablue|7 years ago|reply
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.
[+] Humphrey|7 years ago|reply
Totally agree. I've been using Django since 0.96 and it's is so mature now. Earlier they introduced so many new features... but it's now a very mature framework that doesn't really need any new features.
[+] blackrock|7 years ago|reply
What do you use to write your front end Javascript?
[+] appleiigs|7 years ago|reply
A reminder to support these guys! 24% funded and they’re only asking for $200K. :(

https://www.djangoproject.com/fundraising/

[+] Alir3z4|7 years ago|reply
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|7 years ago|reply
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/ to hopefully work it's way into the near future releases.
[+] theptip|7 years ago|reply
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|7 years ago|reply
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.
[+] mrfusion|7 years ago|reply
There were always ways to get read only in the admin. Just not nicely. It shouldn’t have been holding you back though.
[+] CJST_|7 years ago|reply
I've been looking forward to this as well. A lot of developers underestimate the time it takes to build CMS and resource dashboards (even small ones).
[+] dopeboy|7 years ago|reply
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

[+] paulhallett|7 years ago|reply
Django is the only web framework where I see consistently positive discussions about it on HN.

Bravo Django, and congratulations on another release!

[+] parvenu74|7 years ago|reply
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.
[+] brightball|7 years ago|reply
Are there any good reads on Django for former Rails devs? I'm learning Django now and interested for the "translation".
[+] richjdsmith|7 years ago|reply
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!
[+] appleiigs|7 years ago|reply
Tango with Django is my favourite read but it’s tutorial style.
[+] lowercased|7 years ago|reply
Open question re: django:

https://docs.djangoproject.com/en/2.1/ref/models/fields/#nul...

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|7 years ago|reply
> 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...

[+] trevor-e|7 years ago|reply
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.
[+] scns|7 years ago|reply
Gobuffallo.io the guy who wrote gave a talk which you can find on youtube.
[+] oneweekwonder|7 years ago|reply
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

[+] kennydude|7 years ago|reply
Django's version of that query (to me) looks a little neater too.

    records = Resource.objects.filter(
               data__lastname__exact="Doe"
           )
[+] StavrosK|7 years ago|reply
Fantastic work! After the last few feature-packed releases, I'm happy to see a bugfix one. Upgrading should be a breeze.
[+] Alex3917|7 years ago|reply
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.
[+] blorenz|7 years ago|reply
Agreed, or you end up with something that resembles the unfortunate path of iOS. I'm in the Apple ecosystem so this isn't an attack from an opposite camp, but a matter-of-fact cautionary tale about the kludge which has appeared when components have become untenable and not-so-great performance related.