News for hackers. Stuff that matters.
Re:Django 2.1 released by jtchang on Wednesday August 01, 2018 @12:28PM (#17664041)
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.

Re:Django 2.1 released by borplk on Wednesday August 01, 2018 @01:12PM (#17664517)
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.

Re:Django 2.1 released by andybak on Wednesday August 01, 2018 @01:41PM (#17664870)
> 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.

Re:Django 2.1 released by chipotle_coyote on Wednesday August 01, 2018 @04:17PM (#17666559)
Yes! There are an awful lot of web sites out there--including the one we're on right now--which are, well, web sites, not web apps.

I have a strong suspicion this conflation comes from reasoning kind of like this:

(1) My web site would benefit from some kind of API. (2) Hey, if it has an API, wouldn't it be simpler if it just had an API, and all interaction was through clients? (3) So, [insert JavaScript framework] to the rescue! It'll be just like the original web site, but better!

Except that it isn't automatically "better" for either performance or usability. Content-focused sites tend to perform very well using the server-side model.

Re:Django 2.1 released by KyeRussell on Thursday August 02, 2018 @04:42AM (#17670073)
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).

Re:Django 2.1 released by gkya on Thursday August 02, 2018 @09:45AM (#17671292)
What we have is basically worse than flash. At least nothing serious except video was strictly dependent on Flash.
Re:Django 2.1 released by RobertRoberts on Wednesday August 01, 2018 @03:59PM (#17666384)
It seems you are confusing (conflating?) web pages with web app.

>...constructing elaborate html pages on the server side and pushing it out and letting some basic extra js stuff augment it.

I will take server side rendered webpage up against a fancy js spewed template any day of the week. In every metric possible the server side render wins.

Load speed, SEO, accessibility, file size, time to paint, time to render, time to interactivity. Not a single point goes towards the js rendered web page, period.

In fact, it has almost every conceivable downside, including the obvious, it requires javascript.

I develop webapps for a living, and I hate using them for browsing content, they suck for that. Vue.js/React/Angular for web apps all the way, for web pages/content, server side hands React its behind.

Re:Django 2.1 released by rglullis on Wednesday August 01, 2018 @01:43PM (#17664888)
Not true. django-rest-framework is so well adopted and widespread and it lets you very quickly put together a REST service. If you just want to talk json/xml/whatever with your client, it is easy. But the really cool thing about DRF is how it simply generalizes some of the concepts that already existed in in Django. If you started in Django and learned about Form and ModelForm, you can easily pick up DRF Serializers and ModelSerializers to get input validation.

With django channels, you can also very easily break away from wsgi and have real time services, web sockets, all talking with your Django code.

There is no "focus on older web paradigms". Django may have been slower to get things that other shiny JS frameworks already have, but this is only because Django had already successfully been used in projects of different sizes and it could not succumb to CADT.

Re:Django 2.1 released by vram22 on Wednesday August 01, 2018 @03:25PM (#17666059)
>it could not succumb to CADT.

I had to look up CADT.

Got this via Google:

CADT stands for Cascade of Attention-Deficit Teenagers

Re:Django 2.1 released by KyeRussell on Thursday August 02, 2018 @01:50AM (#17669464)
I love it.
Re:Django 2.1 released by douglaswlance on Wednesday August 01, 2018 @01:44PM (#17664907)
You are not required to use Django's templating engine. It works great with React, Vue, Angular, etc. if you use Django Rest Framework as the intermediary.
Re:Django 2.1 released by augbog on Wednesday August 01, 2018 @04:14PM (#17666521)
Yeah this seems to be the key point that is confused.
Re:Django 2.1 released by blattimwind on Wednesday August 01, 2018 @01:22PM (#17664635)
> because they are focused on an older web paradigm

Which usually is faster and easier to use.

> A modern fancy web application using React in 2018

Takes ages to load and melts your CPU.

Re:Django 2.1 released by messe on Wednesday August 01, 2018 @01:48PM (#17664949)
One wonders if the web would be a better place if developers used machines and networks slower than their users'.
Re:Django 2.1 released by ASalazarMX on Wednesday August 01, 2018 @02:10PM (#17665198)
Definitely. Often adding more hardware is justified because developer time is more valuable, but if you're wasting the time or resources of thousands of users, it shouldn't be acceptable.
Re:Django 2.1 released by dep_b on Wednesday August 01, 2018 @04:01PM (#17666411)
Heh well I'm trying to explain my customers that the load times I'm experiencing could be similar to their users and might be a problem. One of the advantages of being a remote developer with a pedestrian SDSL connection.
Re:Django 2.1 released by dfsegoat on Wednesday August 01, 2018 @04:02PM (#17666424)
Django REST framework (1) gives you the best of django + a RESTful API really, and is just another `pip install` and a few lines added to settings file.

You still have some of the same performance issues as with any ORM - but it makes setting up a Django based RESTful API fairly trivial.

Some things I like about DRF:

- viewsets which allow RESTful read + CRUD ops on an existing django model.

- easy to set up different serializers for a model view: flat, nested with child relations etc.

- auto generated API docs in the browsable format of your choosing.

1 - https://www.django-rest-framework.org/

Re:Django 2.1 released by devxpy on Wednesday August 01, 2018 @09:34PM (#17668624)
Check out my library for using react in Django easily.

https://github.com/pycampers/react-pages

Re:Django 2.1 released by damon_c on Wednesday August 01, 2018 @02:20PM (#17665321)
I haven't used Django to render HTML in at least 3 years.
Re:Django 2.1 released by OmarGonzalez on Wednesday August 01, 2018 @12:40PM (#17664179)
Why would anyone consider it obsolete to begin with ?

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

Re:Django 2.1 released by meowface on Wednesday August 01, 2018 @12:41PM (#17664188)
In the current web dev world, "not the hip new paradigm of the past 3 years" == obsolete in some people's eyes, sadly.
Re:Django 2.1 released by Alir3z4 on Wednesday August 01, 2018 @12:56PM (#17664341)
I would consider that person to be obsolete :D
Re:Django 2.1 released by paulddraper on Wednesday August 01, 2018 @12:59PM (#17664399)
There are not currently many well-known products that use it. (Bitbucket cloud being the exception.)

That's not the best of reasons; just because Django is not used by Google doesn't mean it isn't the perfect tool for you.

Re:Django 2.1 released by txcwpalpha on Wednesday August 01, 2018 @01:12PM (#17664514)
Instagram uses it. I'd say they're pretty well-known.

Others: DigitalOcean, Pinterest (used Django at first, may have moved to Flask by now, not sure), Mozilla, Disqus, Robinhood, The Washington Post.

Re:Django 2.1 released by vram22 on Wednesday August 01, 2018 @03:12PM (#17665927)
IIRC, I had read that Disqus uses Django, and that they were one of the biggest Django sites on the net, but that was a while earlier. Not sure about now.

Update: Just saw that HN user txcwpalpha said the same about Disqus in sibling comment.

Re:Django 2.1 released by douglaswlance on Wednesday August 01, 2018 @01:46PM (#17664928)
Pinterest uses Django.
Re:Django 2.1 released by woadwarrior01 on Wednesday August 01, 2018 @01:18PM (#17664576)
Doesn't Instagram count as a well-known product? :)
Re:Django 2.1 released by KyeRussell on Thursday August 02, 2018 @01:54AM (#17669485)
Last time I checked, last.fm uses Django.
Re:Django 2.1 released by cdnsteve on Wednesday August 01, 2018 @01:38PM (#17664839)
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

Re:Django 2.1 released by KyeRussell on Thursday August 02, 2018 @04:57AM (#17670126)
> * Ease of upgrading between versions. This is especially critical and important if you have long lived projects.

This is such a big deal and I can't work out how the JavaScript community has been operating under its 'break everything in a week' model for so long with such high traction.

Django has a sane, predictable release schedule. Django has LTS releases with years of support. I work in an agency environment where applications can sit running for years without being touched, and when new work needs to be done - I can't have my entire dependency tree falling from under my feet (or arguably worse, abandoned) because people have decided that backwards compatibility doesn't mean anything.

It's so so hard to not be cynical about this. The entire development world feels like it's more-so every day geared toward time-rich development teams pumping out software in a startup environment frothing over the next big thing. I have to account for every hour of my time, switching between / training other developers on new-hotness JavaScript frameworks is unjustifiable.

Re:Django 2.1 released by txcwpalpha on Wednesday August 01, 2018 @12:44PM (#17664222)
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".
Re:Django 2.1 released by danpalmer on Wednesday August 01, 2018 @01:13PM (#17664523)
I’ve had a few frontend engineering candidates quiz me as to why our backend is written in Python and not JavaScript, and implying that Python is “legacy”. This is not true, but there are developers who think that.
Re:Django 2.1 released by ggregoire on Wednesday August 01, 2018 @01:34PM (#17664794)
I'm not a fan of Python but the language is still in the top 5 with C#, Java, PHP and Ruby. It's very easy to get a job as a Python dev. People saying that Python is “legacy” have obviously no idea what they're talking about. They probably think C#, Java, PHP and Ruby are “legacy” too. :)
Re:Django 2.1 released by meowface on Wednesday August 01, 2018 @01:16PM (#17664555)
Would be interested to know how many backend engineers would say something so silly.
Re:Django 2.1 released by baq on Wednesday August 01, 2018 @01:59PM (#17665087)
They're juniors who also think SQL is obsolete because you can't POST a json into it. They'll understand that in order to solve problems efficiently you need a toolbox of a reasonable size.
Re:Django 2.1 released by allyjweir on Wednesday August 01, 2018 @06:20PM (#17667603)
Yep I’ve had this recently too. Three devs joined the team who had no experience in relational databases, didn’t even know what SQL was for.

A few weeks later they told this story of using MongoDB and how they had layered some rules on top to ensure data consistency...

Re:Django 2.1 released by 52-6F-62 on Wednesday August 01, 2018 @01:12PM (#17664510)
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.

Re:Django 2.1 released by KyeRussell on Thursday August 02, 2018 @04:59AM (#17670133)
I develop many content-driven solutions using Django and the conclusion I've come to is that everything is trash and if it's something for your use, stick to MD.

I've gone with CKEditor (https://github.com/django-ckeditor/django-ckeditor) for all my new stuff, for what it's worth.

Re:Django 2.1 released by 52-6F-62 on Thursday August 02, 2018 @10:37AM (#17671731)
Yeah that's what I ended up going with, too.

I might yet switch it out for a plain text editor and just draft all my HTML by hand like scardine has done.

But I don't exactly write a lot these days, so maybe it doesn't matter too much!

Re:Django 2.1 released by scardine on Wednesday August 01, 2018 @02:46PM (#17665658)
I just use plain text-areas and markdown - it avoids a lot of footguns from text-editor-like widgets.
Re:Django 2.1 released by swah on Wednesday August 01, 2018 @02:35PM (#17665533)
Another point: websockets. Golang is pretty good and (they say) Django kinda sucks. Have you used Django channels?
Re:Django 2.1 released by scardine on Wednesday August 01, 2018 @02:43PM (#17665630)
I have and it works but they completely revamped the implementation in 2.0. I'm procrastinating the upgrade because it is a royal pain.