Live data from Hacker News

Django Newbie Mistakes

code.djangoproject.com

51–60 of 225 posts

Re: Django Newbie Mistakes

#51
post #13

I feel like I just got into a time machine - this is the top post on hacker news? People are learning Django in 2018? I guess its fine if you have a small project and aren't going to see much traffic, but Python is so slow and difficult to maintian compared to (e.g.) Go. I say this as someone who worked in Python for a long time, and on several large Django projects.

What makes Go projects easier to maintain?

I would argue that it's simplicity. I believe I've read somewhere that Golang was designed with junior engineers in mind. They wanted to create a language that young engineers could learn easily yet cannot make a lot of mess due to its simplicity.

They baked all features necessary right into the language. You get a http server, ssl support, templating engine etc. right in the language. You also have a database agnostic database driver right in the language. Python is also similar in many ways, it comes with "batteries included". But in my experience go standard library is written in a crystal clear straight-forward way. My workflow (and I believe the workflows of many programs) always involves jumping to the source of go standard library and just reading the code.

Django on the other hand has layers and layers of magic, you've got an ORM, modules etc. etc. Some people might like to let a framework handle everything, learn it inside and out and use it. But for other people like me, with a short attention span, django seems subjectively boring. Maybe if I didn't program as a hobby and it was my job to learn django I might have taken the time and learn it.

I started the django tutorial twice in the last 2-3 years. Both the times, I got bored and left. My subjective opinion was that it didn't teach me anything besides how to "generate" a site with Django. OTOH I had much more luck with Flask. Immediately after following the tutorial I was able to write websites and deploy them.

I think it's a matter of taste. I don't like big frameworks, I like to keep things very simple and minimal. My favorite OS of choice is OpenBSD, my favorite languages are C, Golang and Python. I don't like to use IDEs, I use Emacs, even Emacs feels a bit bloated sometimes.

From time to time I get the urge to try one of the big frameworks like Rails and Django, but I never quite got them.

Re: Django Newbie Mistakes

#52

My standard tool for quickly spinning up a web app is Rails, but recently I've been writing a lot of python for data projects and I'm thinking about spending some time learning Django. Rails development seems to be going strong though and has me a little worried. Can anyone speak to Django development and its ecosystem in 2018?

Django in 2018 is still a very vibrant and active community. The project is actively developed, there is a lot of sponsorship from big companies (instagram etc) funding a dedicated fellow who's job is to work on Django full-time.

The plugin ecosystem is very rich and active too - almost always a pre-made package for some feature or implementation you want to add to Django.

Re: Django Newbie Mistakes

#53
post #21
post #2

If you're writing a REST api, invest the time to learn Django Rest Framework. It is well worth it.

DRF is nice enough 90% of the way, but when you need to do something that its authors haven't really thought of, you need to dig in very deep to fix things, I've found. :/

DRF's code is realtively easy to read and it's designed in a way where you can just roll your own parts quite easily.

Re: Django Newbie Mistakes

#54

A lot of these things are only common mistakes because of Django's unusual behavior. > POST to views loses POST data The middlewares shouldn't be redirecting POSTs then! They could have returned a client error instead. > Blank object names They could have provided a fallback of __class__.__name__. > Integer & NULLS If the admin interface knows the field is required, why does it even attempt to insert a null value? It…

Up until 90 minutes ago the previous change to this was 8 months ago. Before that it was 4 years ago.

I think you might be complaining about out of date documentation :)

Given django's docs are impressive, I doubt this is used actively by people.

Re: Django Newbie Mistakes

#55

Earlier quoted context omitted.

Too many issue to enumerate them here, but there are just a lot of things that are likely to lead to security vulnerabilities or hidden performance problems. I'm planning to write a blog post on this in the next few weeks.

How do I subscribe to get it?

I'll post it here, you can subscribe via email:

http://alexkrupp.typepad.com/

Re: Django Newbie Mistakes

#56

A lot of these things are only common mistakes because of Django's unusual behavior. > POST to views loses POST data The middlewares shouldn't be redirecting POSTs then! They could have returned a client error instead. > Blank object names They could have provided a fallback of __class__.__name__. > Integer & NULLS If the admin interface knows the field is required, why does it even attempt to insert a null value? It…

> To me, the Django project exudes the stubbornness of the developers who maintain it because rather than fixing these problems they've decided to write this page about how it's you, the user, who is wrong.

I sometimes feel that, similar to how perl's motto is "There's more than one way to do it", some python developers have converged on an unofficial mottot of "You're doing it wrong".

Re: Django Newbie Mistakes

#57
post #3

Django’s documentation is still the best I have worked with so far of any software project I came across to date. It not only explains, it educates.

I vastly prefer Flask's documentation (http://flask.pocoo.org/docs/). It explains everything from a perspective of what your use case would be, and they've gone above and beyond in covering use cases that might otherwise have been deemed outside their scope.

Re: Django Newbie Mistakes

#58

A lot of these things are only common mistakes because of Django's unusual behavior. > POST to views loses POST data The middlewares shouldn't be redirecting POSTs then! They could have returned a client error instead. > Blank object names They could have provided a fallback of __class__.__name__. > Integer & NULLS If the admin interface knows the field is required, why does it even attempt to insert a null value? It…

Up until 90 minutes ago the previous change to this was 8 months ago. Before that it was 4 years ago. I think you might be complaining about out of date documentation :) Given django's docs are impressive, I doubt this is used actively by people.

I use django at my day job, every day for the past two years. I didn't know this page existed, and better yet, I've never run into these problems

Re: Django Newbie Mistakes

#59
post #25
post #2

If you're writing a REST api, invest the time to learn Django Rest Framework. It is well worth it.

Isn't Flask simpler for REST stuff?

Only if you need to implement simple CRUD API. But if you need filtering/ordering/authorization/complex serialization/unconvential request parsing -- you would need to implement a lot of stuff or install a lot of packages and find a way to make them work together. DRF makes all this things for you.

Re: Django Newbie Mistakes

#60
post #36

One of the things that makes me sad is there is no project even remotely close comparable to Django for say Golang or Scala. I love the fact that you get an admin interface out of the box. And tons of documentation. The views/template stuff is a bit dated since everyone started moving to frontend/backend services and SPAs but we still have DRF which is incredible in the amount you get for "free". I've had the "pleasu…

> One of the things that makes me sad is there is no project even remotely close comparable to Django for say Golang or Scala.

Could not agree more. This is my number one reason for not moving away from Python for web stuff.

> The views/template stuff is a bit dated since everyone started moving to frontend/backend services and SPAs

This is certainly true for customer facing products, but for internal tools I've yet to see anything that beats the speed of development for server-side rendered basic HTML pages. 80% of the pages we have in our Django application are internal facing (we don't use the admin due to it being a poor fit for particular reasons).

Post reply on HN