Live data from Hacker News

Django 3.1

djangoproject.com

41–50 of 209 posts

Re: Django 3.1

#41
post #34

Earlier quoted context omitted.

I'm not sure you're talking about the same thing, this is about asyncio/green threads.

re-read the documentation but I'm not following. This example: async def current_datetime(request): now = datetime.datetime.now() html = ' It is now %s. ' % now return HttpResponse(html) seems like an example that I was thinking of.

I don't know what you're thinking of, unfortunately, but that piece of code just returns the current date when you visit the page.

Re: Django 3.1

#42

Slightly OT: How does HN feel about the recent craze to make web python asynchronous? To me, the performance gains are dubious in many cases and the complexity overhead of handling cooperative multitasking just seems like a step back for a language like python.

90% of the time I don't want it. Database, cache, etc, not really that bothered. Web requests take 100-300ms to complete, tying up a worker for 300ms isn't much of a problem.

10% of the time I'm calling an API that takes 3s and tying up a worker for 3s _might_ be a problem. Being able to not do that would be really handy sometimes.

Not web servers, but I also do a lot of web scraping and Python is definitely the best tool I've used for that job (lxml is fast with great XPath support, Python is very expressive for data manipulation), using async for that could dramatically improve our throughput as it's essentially network bound, and we don't really care about latency that's in the 10s of seconds.

Source: I work on a large production Django site.

Re: Django 3.1

#43
post #8

Pardon the rant, but I feel that the advantages don't outweigh the fact that with each release some of my stuff gets broken and I need to adjust. Django puts DeprecationWarnings basically everywhere and it's a hell to maintain projects that had been alive for a few years. God forbid you do anything with the interfaces they expose. The problem is only getting worse when you consider your dependencies, which in many ca…

> Django puts DeprecationWarnings basically everywhere

This seems like exactly the way that deprecations should be handled. Are you suggesting they should maintain backwards compatibility for much longer? They already have a pretty long deprecation policy.

Re: Django 3.1

#44
post #29

Earlier quoted context omitted.

I am good with Python and C#

Then ASP.NET is probably the superior choice. C# is a better language by far and the .NET runtime is a better runtime by far. It only ever makes sense to use Python for data-science one-offs and munging if you have competency in Java/C#/etc. It's not a language well suited to application development.

Don’t understand why you got downvoted. I work in a Python shop and 100% agree with you.

Re: Django 3.1

#45
post #6

JSONField has been an absolute godsend in combination with Django's ORM. I had been using it with Postgres and will likely keep our backend the same, but I cannot recommend it enough. You will have to write some validation and schema code on top if you want your data to have similar (but weaker) guarantees to the usual typed fields; the benefits from the flexibility you get are immeasurable though.

Typical use case: There are a number of required fields that your app won't work without. Those should be columns, probably non-nullable columns. Then there're a bunch of optional fields. Traditionally, a number of nullable cols would be created. But they're ultimately messy (need to null check every accesses) and unneeded since you can replace them with a single json item. Keys are always optional, so you always nee…

Fields are messy because you have to check for nulls, yet JSON keys aren't messy because you have to check for nulls?

Re: Django 3.1

#46
post #29

Earlier quoted context omitted.

I am good with Python and C#

Then ASP.NET is probably the superior choice. C# is a better language by far and the .NET runtime is a better runtime by far. It only ever makes sense to use Python for data-science one-offs and munging if you have competency in Java/C#/etc. It's not a language well suited to application development.

>C# is a better language by far and the .NET runtime is a better runtime by far.

Big nono!!

Re: Django 3.1

#47
post #44
post #29

Earlier quoted context omitted.

Then ASP.NET is probably the superior choice. C# is a better language by far and the .NET runtime is a better runtime by far. It only ever makes sense to use Python for data-science one-offs and munging if you have competency in Java/C#/etc. It's not a language well suited to application development.

Don’t understand why you got downvoted. I work in a Python shop and 100% agree with you.

Because he say's a hammer is far better then a screwdriver, and Metal is far superior to wood.

Re: Django 3.1

#48
post #44
post #29

Earlier quoted context omitted.

Then ASP.NET is probably the superior choice. C# is a better language by far and the .NET runtime is a better runtime by far. It only ever makes sense to use Python for data-science one-offs and munging if you have competency in Java/C#/etc. It's not a language well suited to application development.

Don’t understand why you got downvoted. I work in a Python shop and 100% agree with you.

Look at the number of sweeping absolutes presenting their opinion as a global truth, with no supporting evidence presented.

Threads which start like that rarely end up contributing anything of value or convincing anyone who didn’t already agree with the author.

Re: Django 3.1

#49
post #6

JSONField has been an absolute godsend in combination with Django's ORM. I had been using it with Postgres and will likely keep our backend the same, but I cannot recommend it enough. You will have to write some validation and schema code on top if you want your data to have similar (but weaker) guarantees to the usual typed fields; the benefits from the flexibility you get are immeasurable though.

In projects I've been involved with, storing JSON in the database has often turned out to be a mistake. Django models create a well-defined self-documenting structure for your schema, are easy to evolve using migrations, and there's a wealth of tooling built on top. IMHO, these far outweigh the perceived convenience of simply storing some stuff in a JSON field. If you find yourself implementing your own validation an…

I think there was a bit of a confusion on the implied use case of our project. As another commenter pointed out, when the data is user supplied and is not always uniform in nature, creating migrations for each adjustment to the custom fields they can modify becomes virtually impossible. I ended up settling for JSON fields because I don't have to migrate the data or the database schema; I can just do a best-guess conversion for the data when it hits the UI, and supply some validation warnings if it really doesn't make sense (e.g. a non-date string somehow makes it into a "date" field).

Re: Django 3.1

#50
post #29

Earlier quoted context omitted.

I am good with Python and C#

Then ASP.NET is probably the superior choice. C# is a better language by far and the .NET runtime is a better runtime by far. It only ever makes sense to use Python for data-science one-offs and munging if you have competency in Java/C#/etc. It's not a language well suited to application development.

I work mostly in Python and I like it. However, C# is a great, and for some reason underrated, language that is certainly better along a number of dimension.
Post reply on HN