Live data from Hacker News

Django Newbie Mistakes

code.djangoproject.com

101–110 of 225 posts

Re: Django Newbie Mistakes

#101
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.

> People are learning Django in 2018? I am. So, yes.

I am too.

Re: Django Newbie Mistakes

#102
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…

This is exactly my view as well. Every time I've used Flask, I ended up regretting it, because I've invariably needed to fit something to it that would have worked out of the box with Django (or at least integrated much more easily). I haven't found any reason to use Flask in a project, except maybe for small, ad-hoc scripts that you want to run in a single file.

And its perfectly possible to write a one file/ten loc Django app. Everything is optional. Its just there by default, because 99% of projects will need it anyway.

Re: Django Newbie Mistakes

#103
post #16
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.

I agree in principle that python for web can be slow, but plenty of sites have been able to scale with it (e.g. Reddit, Pinterest, Quora). So I think saying that python is only for projects that aren't going to see much traffic is a very broad and unfair generalisation.

scalability and speed are two very different beasts. You can build scalable things in Go, or Python, or most any language.

At a certain scale though, the amount you'd save in infrastructure bills by using Go instead of Python is absolutely stupid. A 10x difference would not be surprising in the slightest.

Re: Django Newbie Mistakes

#104
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.

Oh man! I feel where you are coming from but who clicked on this link except Django fans? That's like walking into a Django club and telling everyone their framework sucks. Even as a member that only gets you so far. I can't believe you also called it difficult to maintain! Because when you say slow, the response its easy to maintain, and you went ahead and called it difficult to maintain? At least give us a reason.

Ha, ok - Django is not difficult to maintain, Django is a very powerful, carefully built framework with tons of features that can get you up and running with a production ready website very quickly.

Python is difficult to maintain. Full stop. Why? Anything in Python can do anything to anything else - there are no boundaries which makes it basically impossible to reason about code at scale. You need very strictly enforced code quality standards across your entire codebase and libraries in order to be able to trust anything - otherwise you don't know if some method on a class has been swapped out right underneath your feet, or if some field access is actually calling a function which is accessing a database.

Go is super easy to reason about compared to Python - as long as no one is importing unsafe or reflect (easy to check), you have very solid guarantees as to what can happen at any point.

Re: Django Newbie Mistakes

#105
post #72

Earlier quoted context omitted.

> I've had the "pleasure" of working with other large projects built on flask and ever time it gets to a certain size I wonder why we didn't just use Django. Actually, I've had the exact opposite experience. I like using Django for small and mid-sized projects, because with Flask I have to spend time adding all these extra libraries for universally required functionality on a quick app whereas, with Django it's plug…

Agreed. Also, unless django has changed peaking under the hood is a nightmare. Forms and the ORM (and really the whole framework) is giant ball of mud.

Forms are a nightmare to work with. It's a component in Django I systematically avoid, even when using actual forms.

Nowadays I use DRF for everything though. Serializers > Forms. And React > Templates.

As for the ORM, I long for a world where the ORM is replaceable by SQLAlchemy. Django's ORM is nice and simple, but as soon as you want typed complex queries, SQLAlchemy is really good.

Re: Django Newbie Mistakes

#106
post #97
post #86

Earlier quoted context omitted.

What’s the motivation for moving away from python?

We are in python 2.7 and we need to migrate the application to python 3.0 For me it's another language to learn if we want to make good python 3 code. Python/Django/DRF is a stack with very poor performance if you are dealing a lot with JSON. We already have API points in golang with very good performance. No need to deal with nginx/CGI etc. nightmare. Conclusion was that our code in golang has a lower downtime. (Typ…

You might want to try using Pypy as your interpreter as a potential drop-in fix.

Re: Django Newbie Mistakes

#107
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.

How large are we talking? Do you consider Instagram large? If so, you should let them know they should stop using Python and Django.

I'm sure they could save a massive amount of money and improve their latencies if they did.

Re: Django Newbie Mistakes

#108

Earlier quoted context omitted.

> 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…

Personally, as a customer, the "new" way of doing it is irritating, usually somewhat broken, slow and usually unreliable. I wouldn't be surprised if non-techies couldn't give a toss if you're using a traditional MPA with a sprinkling of ajax for the bits that really need to be responsive or a total SPA. I'm beginning to suspect the only people who want a SPA are the programmers. Has anyone even got any proof that a S…

Good SPAs are fantastic. It's just a lot of people suck when implementing them.

The Serverless documentation, an SPA, blew my mind in terms of how fast and clean it is: https://serverless.com/framework/docs/

Re: Django Newbie Mistakes

#109

Earlier quoted context omitted.

> 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…

Personally, as a customer, the "new" way of doing it is irritating, usually somewhat broken, slow and usually unreliable. I wouldn't be surprised if non-techies couldn't give a toss if you're using a traditional MPA with a sprinkling of ajax for the bits that really need to be responsive or a total SPA. I'm beginning to suspect the only people who want a SPA are the programmers. Has anyone even got any proof that a S…

I think with server side pages, you’re limited in how much you can mess it up, but very limited in how far you can take the experience.

With single page apps you have to do a lot more to get back to what server side pages give you, basic browser functionality, and as a result you can end up with worse experiences. However if you’ve got the development resources it can be a far better experience and enable applications that just wouldn’t be usable or even possible on server side rendered pages.

Re: Django Newbie Mistakes

#110
post #69

Great post, though this bit stuck out for me: current_zip = meta.IntegerField(max_length=5, blank=True) You should not store zip data as an integer as they can start with 0. Zip codes use numbers, but aren't actually numbers themselves (leading zeros, no arithmetic, etc). Plus, someday you'll want to ship something to Canada.

It's even worse: zip codes can contain letters and spaces in United Kingdom: https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdo...

And they are not called zip codes.
Post reply on HN