Live data from Hacker News

Django 3.2

djangoproject.com

121–130 of 195 posts

Re: Django 3.2

#121
post #83

It's a shame that Django's templates are still so bad. You can't just import and call some arbitrary python function. You most likely need to write a template filter or tag [0]. Maybe there's a good reason for this but it just feels like I'm working around a weird issue in the framework. Also, I can't use parentheses inside if statements in a template. It's a strange restriction. I know that Jinja2 -- which is good -…

I think a lot of developers have moved to reactjs calling an api.

Basically doubling the complexity of an app. If you need a fair amount of front end interaction, fair enough, but many apps would be a lot simpler with Django templates and a bit of jQuery.

Re: Django 3.2

#122

Any one have any pointers to learn the Django stack from the basics? Any specific video course or a book? "Two Scoops of Django" was recommended to me by someone on HN. I think it is currently being worked on for Django 3. It is on my reading list.

The Django Girls tutorial is a nice starter tutorial for beginners.

https://tutorial.djangogirls.org/en/

Re: Django 3.2

#123

Congratulations to the Django project and contributors on a big LTS release. And a huge thank you for the consistently excellent framework that so many have built their web dev careers on. I'll post this as a Show HN soon, but I'll mention it now as a soft-launch introduction. After a decade of using Django I started a project I always wanted to exist: backported security and bug fixes to old versions that the Django…

Awesome project! Bookmarking for sure. Dumb question: after signing up, am I getting some access to a privately hosted repository(pypi.codestasis.com)? How is the mapping between personal/pro plans and features done? Are different plan levels using different repository?

Btw, might have overlooked, if I'm purchasing for my org, I would like to look at the commercial license. Can you point me to it? Or put it online if not currently available? I'm not using your service at this moment, so feel free to ignore the request as well.

Re: Django 3.2

#124
post #54

I'm more if a flask man myself. Worked with django only when I had to. Maybe I'm wrong?

Honestly, I don't see the point of using Flask anymore. You can set up a Django project and just use a single module with a bunch of view functions, built-in testing and sensible defaults. Done. Not choosing that approach just because it takes a few more MBs on disk or needs a few more KBs of memory is shortsighted, IMO. You can't always predict what a project will end up needing. I'm legitimately asking: why would y…

Because Django is pretty badly designed, and it can get in the way when you need to do some more complex stuff. It get's the job done for 95% of cases, but that extra 5% can devolve into some pretty nasty stuff.

Typically the inflection for when Django becomes a nightmare is when you want to start splitting the application up. This is made really hard because Django depends on a whole load of globals (settings, urls, context preprocessors, the actual WSGI handler). With Flask you can have two separately configured applications running in the same process, routed with a bit of WSGI middleware.

This comes in handy when you need to do a 'soft' rewrite and have code running side by side. This also just makes things easier to test, because you can build a new application object for each test with it's own settings. You can't do that in Django with out a great deal of consternation; try creating two tests with different middleware stacks in Django, patching settings won't work because the application has already loaded, and there's no way to reload it between tests.

Also, for the same reason (as someone else said) it makes it tricky to use in non-web contexts. Like Celery.

Django's can't handle more complex database queries. If you've ever seriously used SQLAlchemy, you'll know what you're missing.

The ORM is also lacking a unit of work model, which can kill performance. The only way to create multiple objects in a single database round trip in Django is with `bulk_create`. But you can't create something like a group and then a user in a single database round trip. Sure you can create them in a single transaction, but that's not quite the same, because each roundtrip takes an extra millisecond. It's an easily avoided inefficiency that SQLAlchemy solves.

The template language is limited compared to Jinja2. While this is by design, it doesn't support streaming the response back. This is really annoying if you're generating massive templates. It would have also been really simple to do.

I could go on really.

Re: Django 3.2

#125

Congratulations to the Django project and contributors on a big LTS release. And a huge thank you for the consistently excellent framework that so many have built their web dev careers on. I'll post this as a Show HN soon, but I'll mention it now as a soft-launch introduction. After a decade of using Django I started a project I always wanted to exist: backported security and bug fixes to old versions that the Django…

> It's free for personal use and a paid subscription for businesses and organizations. This is awesome.

Great project. Looks like running outdated Django will be cheaper than running outdated rails... Although I can't remember if there were multiple players delivering "lts" versions for ruby/Rails?

https://railslts.com/

Re: Django 3.2

#126

Any one have any pointers to learn the Django stack from the basics? Any specific video course or a book? "Two Scoops of Django" was recommended to me by someone on HN. I think it is currently being worked on for Django 3. It is on my reading list.

Tango with Django was by far the best resource I've used. Two Scoops is more for people who have a django project already and want to learn best practices of django.

The latest version of Tango with Django is from 2019 and is compatable with Danjango 2.2. Has a lot changed since then, if one was to work with 3.2?

Re: Django 3.2

#127
post #121

Earlier quoted context omitted.

I think a lot of developers have moved to reactjs calling an api.

Basically doubling the complexity of an app. If you need a fair amount of front end interaction, fair enough, but many apps would be a lot simpler with Django templates and a bit of jQuery.

Agreed. This is why I created a library to render JSX through Django. See it here: https://github.com/silviogutierrez/reactivated/

Both my personal blog and business run on it in production. See my profile for links.

The biggest issue was deploying it since you need python and node. Still a work in progress, and docs are severely lacking.

But I did add a single-click deploy to Heroku:

https://dashboard.heroku.com/new?template=https://github.com...

Re: Django 3.2

#128
post #38

Earlier quoted context omitted.

The ORM is horrendous.

Can you elaborate? I've been using it for years and it mostly does what I want. It's an ORM and obviously sometimes generates unefficient queries I need to manually amend/refactor but otherwise I don't see any major issues with it? In contrast I've looked at SQLAlchemy with Flask and I couldn't even wrap my head around declaring models (which inherit from the DB connection object if I remember correctly, so potential…

The inability to batch network calls in a single unit of work makes the ORM needlessly slow. That's also one of the main advantages to managing transactions/session yourself. It can save a huge number of round trips in a complex view.

The Django ORM itself is also slow at generating SQL. Recently I was bemused by a query, which took 500us to actually be generated. This wasn't doing anything particular wild, it just had a `select_related` call to an object that had about 50 fields (not great DB design, but beyond my control). The query actually took longer to build than it did to run.

That itself wouldn't be an issue if you could LRU cache the SQL query itself. But you can't, it's Django.

Re: Django 3.2

#129
post #17

If anyone is curious I just updated my Docker / Django starter project to use 3.2. It uses Docker Compose + Django + Celery + PostgreSQL + Redis + Webpack + TailwindCSS and it's available at: https://github.com/nickjj/docker-django-example As an aside it's also using TailwindCSS 2.1 with the JIT compiler enabled.

This is awesome, thanks for sharing. I maintain a similar boilerplate (graphene + semantic ui). What's your take on Tailwind so far? I've found the lack of a react offering has really slowed me down.

The creators of TailwindCSS also have a paid offering called TailwindUI (just pre-created components with documentation for your application and marketing site) that has React support. It also comes with Figma mockups for each component. It's a bit pricy but very high quality.

Re: Django 3.2

#130

Any one have any pointers to learn the Django stack from the basics? Any specific video course or a book? "Two Scoops of Django" was recommended to me by someone on HN. I think it is currently being worked on for Django 3. It is on my reading list.

I would grab the "Django Crash Course" from Feldroy[0]. It is a tutorial starting from nothing, and you build a very basic app. Which sounds unimpressive, but it shows you all the best practices for app layout etc and when combined with Two Scoops, provides a great foundation.

After that, to really get to know Django, you'll want to do some "unconventional" things like use a class based view for a page with 3 forms... That should give you the "ah ha" moment.

[0]: https://tinyurl.com/2hkhd6px

Post reply on HN