Live data from Hacker News

Django 2.0 released

docs.djangoproject.com

51–60 of 177 posts

Re: Django 2.0 released

#51
post #37

Earlier quoted context omitted.

I’d posit that a simple crud app would take an order of magnitude less time with Rails. I’ve been a Django developer since 0.96 and have built dozens of apps with it. After transitioning to Rails, it’s hard to justify the use unless you’re in an evironment that absolutely must use Python.

Interesting. What would you say is the biggest reason for this >10x development speed difference?

Django forces you to declare everything. Lots of manual boilerplate. Example, you must define every bit of a model in order for it to work. Rails is the opposite. ActiveRecord will ‘just work’ with the database. You can run rails on an existing db for example if it follows what are widely used conventions such as lowercase model name is the table, foreign keys are foo_id, etc...

This is where people fear the “magic” of things like pluralization of models to table name and introspection... but it’s all just code! You can read it and look at it and understand it. No magic here. Just convenience and a smaller mental model as an end developer.

Also... resources as a first clsss citizen is the biggest reason and the reason it defeats Django for this use case. You define ‘resources’ in your routing layer instead of just routes that map to a function. This allows you represent multiple crud actions with a single controller and even nest them, all with a few lines of code. Then you get access control for free on your sub resource, knowing you’ve already passed the parent checks and have that context.

Example: /users/:id/photos/:id

In this case, my Photos controller will already know who the user is (and if they can view these photos) based on work that the parent did. It’s single responsibility principle. You can even have a top level photos resource devoid of the user context and support both cases with minimal effort.

Yes, you can do these things in Django. But it’s not designed to make these things composable and seamless. I’d argue it’s not REST-friendly. Don’t even get me started on Django Rest Framework which is a massive beast in and of itself.

You get all of that out if the box on Rails. You can stand up extremely robust and ergonomic API’s with so little code you’ll feel like your cheating.

I should probably write a blog post.

Re: Django 2.0 released

#52
post #44
post #26

Earlier quoted context omitted.

There have been lots of breaking changes along the way. Django is pretty good at giving developers a heads up of what is deprecated and slated for removal, but there have been lots of growing pains in the 1.x release cycles.

I really dread upgrading Django. We have a codebase that has been with us since the 1.3 days and each time there's an upgrade, someone on the team sets about one month aside to deal with all of the breakage. You could say that this is our fault for "doing it wrong" but we just wanna get stuff done. Sometimes the only way to do it that we could figure out was by doing something that Django later decided we shouldn't h…

That's surprising to me as I have updated a large production Django code-base on my own for every version from 1.5 to 2.0 and it has never taken me more than a day, with an equal or lesser (typically lesser) amount of time dedicated to deprecations when I updated to the previous version. Any blockers past that point have always been due to slow-to-update third-party libraries.

The Python 3 update took longer and had a longer legacy of surprise breakages, but I don't ding Django for following the intended life cycle of Python.

Re: Django 2.0 released

#53

Earlier quoted context omitted.

How about performance? Bugs that might come up due to the implicit nature of Rails? Just curious, since you have seen both sides.

The implicit “magic” thing isn’t a real thing. It’s a fallacy. I have not come across real world problems like this.

Well. I disagree that it is not a real thing. For better debugging, you need to know more what's behind the scenes. Personally, I have seen some of my colleagues struggling to find the cause or better architect the thing because most of the decision has been hidden/taken by the framework. Not saying, it's true for all Rails dev but for some beginners, it really bites them.

Re: Django 2.0 released

#54

Respect to the Django team that even after 12 years they have only one major version shift (which seems to only because of dropping support for Python 2) and the backwards incompatible changes are minimal.

The plan going forward is to make every third release semver-major, but these will still be incremental releases. The semver-major ones will be backwards-incompatible only in that they'll drop support for features that had already been deprecated for at least two releases.

Right. It’s a change in version numbering scheme. Not any major backwards compatibility. It will bump every two years from now on.

Re: Django 2.0 released

#55

Earlier quoted context omitted.

The implicit “magic” thing isn’t a real thing. It’s a fallacy. I have not come across real world problems like this.

Well. I disagree that it is not a real thing. For better debugging, you need to know more what's behind the scenes. Personally, I have seen some of my colleagues struggling to find the cause or better architect the thing because most of the decision has been hidden/taken by the framework. Not saying, it's true for all Rails dev but for some beginners, it really bites them.

Sure but there is magic everywhere. You trade convenience for the risk of not knowing the underlying mechanism in action. The inverse is long boilerplate code, setting up multiple services and factories and fooWidget stuff just to do a simple thing. It’s more clear, yes, but is it always better?

Rhetorical question by the way... just food for thought. There is a balance. I happen to love the convention rails imposes and the “magic” it offers. That being said, there isn’t anything about it that I consider wizardry or don’t understand. It’s just ruby.

Re: Django 2.0 released

#56
post #4

This is probably your best bet if you're just going to build a nice CRUD frontend for a business app, possibly with an API (via DRF). I am doing this right now on a project as it's the shortest path to a win. The API however is written in Java 8 / vertx.

Also APIStar from the creator of DRF is something to keep an eye on. It has Django integrations and I believe is async.

+1 for APIStar. I love Django but if all you want to build is an API, it can be a bit much. APIStar has been great so far in the one production API I've helped build even if there are a few pain points that come with using such a new framework.

Re: Django 2.0 released

#57
post #4

This is probably your best bet if you're just going to build a nice CRUD frontend for a business app, possibly with an API (via DRF). I am doing this right now on a project as it's the shortest path to a win. The API however is written in Java 8 / vertx.

i vote turbogears for crud apps

Re: Django 2.0 released

#58
post #37

Earlier quoted context omitted.

Interesting. What would you say is the biggest reason for this >10x development speed difference?

Django forces you to declare everything. Lots of manual boilerplate. Example, you must define every bit of a model in order for it to work. Rails is the opposite. ActiveRecord will ‘just work’ with the database. You can run rails on an existing db for example if it follows what are widely used conventions such as lowercase model name is the table, foreign keys are foo_id, etc... This is where people fear the “magic”…

Have you tried Django’s inspectdb?

Re: Django 2.0 released

#59
post #32
post #27

Earlier quoted context omitted.

I am learning Python right now and want to build a website using this programming language. Django and Flask seem to be the best frameworks for this purpose. I understand that Django has steeper learning curve and comes with "everything", whereas Flask is more modular and compositional. If I were to use Flask, is there anything that I could not do but that Django could?

The advantage of Django is it comes bundled with everything you could need. Flask is simple, but then you need user authentication. Which library do you use? Is it updated and maintained? What about an ORM, forms, templating, localzation. Do they all work together? Suddenly it's not so simple. That being said, if your app really is simple (single file, under 100 lines) flask is excellent.

Oh, come on. There are plenty of large websites written in flask. It's not that hard to use at all, and all those things you list are definitely a part of it. Hell, I have a 20 KLOC website written in bottle, and no one ever said it was poorly done, insecure, and so on.

The problem is that a lot of people writing Python web stacks don't know how to write Python at all, and no framework will save that shortcoming.

Post reply on HN