Live data from Hacker News

Django Newbie Mistakes

code.djangoproject.com

11–20 of 225 posts

Re: Django Newbie Mistakes

#11
post #2

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

Seconded. It provides an API similar to that of Django's various Form classes. It should feel somewhat familiar, even to newcomers. Their documentation is also great with rich examples and explanations.

Re: Django Newbie Mistakes

#12
post #8

Django is a hell for APIs and big projects. It's good for beginners and small projects, but once you need the least amount of actual control, you will find it's too late

Can you provide some examples?

I've worked on plenty of large projects and haven't run into places were I've "lost control". Just the opposite, I have found it to be very extensible.

I'm curious if there are cases I haven't hit that you have, though.

Re: Django Newbie Mistakes

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

Re: Django Newbie Mistakes

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

Does go have a web framework that does as much for you as django?

Re: Django Newbie Mistakes

#15
post #8

Django is a hell for APIs and big projects. It's good for beginners and small projects, but once you need the least amount of actual control, you will find it's too late

I read this a lot, but I do not agree. Worked on quite large (and busy) websites, did not experienced problems with exactly that. And if the project really is that large, perhaps it is time to split things up? (I intentionally avoid the term microservices, because there are more ways to split things up.)

Actual control... where? And why is it too late? Too late for what?

You can get actual control everywhere if you want to. Doing raw sql queries is perfectly possible. Rendering with jinja instead of django's template system is possible. Speaking to redis directly: possible. Returning a string instead of something rendered: possible.

Heck, even speaking to the django db from another project with sqlalchemy worked out quite alright.

A big problem in large projects is too many queries per view, or unoptimized queries. Django's orm often gets the blame. But I did see that happen with ORMs in other frameworks as well (flask, bottle although an orm is optional). Even raw sql. Another nice feature of django 2.1 will be the .explain() method on querysets. Im using 2.1 to debug queries now and switch back to 2.0 when things are speedy again.

Another problem is having way too many unused variables and unclear calls to database from templates. But that is also a big problem in flask etc.

I think it is a myth Django is a hell for big projects, there are plenty big companies and websites which prove im right. Of course there are struggles. But those struggles are there with other python frameworks as well.

A lot of work happens quickly beyond the framework you use anyways. When a website grows many background jobs have to run or many business rules have to be programmed at some place. This does not have to do with the framework and often times just happens to become messy. I think of the work i do in django projects 30% is django related 70% is django unrelated.

You can consider to use another _static_ language and framework for speedups, like play or something. But i think the parent poster meant Django is a hell compared to other python frameworks.

I do wish django could do some async stuff, like the play framework does. It would be just nice to fire off a few db queries and resize an image and just wait for the result at the moment you build the response. But other than that it is superb!

Re: Django Newbie Mistakes

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

Re: Django Newbie Mistakes

#17
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?

Re: Django Newbie Mistakes

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

Re: Django Newbie Mistakes

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

Re: Django Newbie Mistakes

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

Does go have a web framework that does as much for you as django?

I know this was rhetorical, but no, it doesn't
Post reply on HN