Live data from Hacker News

Django 2.1 released

docs.djangoproject.com

31–40 of 129 posts

Re: Django 2.1 released

#31

To django model users. Can you query keys inside a JSON datatype(pgsql)[0] from the ORM? For example in sqla you will do: records = db_session.query(Resource).filter( Resources.data["lastname"].astext == "Doe" ).all() with data being the json column and lastname a key in the column. [0]: https://stackoverflow.com/a/29975187

Django's version of that query (to me) looks a little neater too.

    records = Resource.objects.filter(
               data__lastname__exact="Doe"
           )

Re: Django 2.1 released

#32

Earlier quoted context omitted.

What do you use to write your front end Javascript?

Not OP, but I've also been using Django for (more than) my whole career and I use React on the frontend. If you're curious about the frontend path I took, it was roughly: * jQuery with no framework * Backbone (for a couple years) * Backbone + Marionette (for a couple more years) * Angular (for about a week) * React (for the past few years)

I’m curious what makes react your top pick?

Re: Django 2.1 released

#33
post #29

Earlier quoted context omitted.

As a counter point, I tried to use Django for a data-visualisation project and ran into some problems. Everything is built on models, which are kind of activerecord pattern. Django has an inbuilt (and inferior) version of sqlalchemy, so that when you want to push sql past a certain point (define queries more complex than the api) you're pretty much stuck. Now you have codebase with two different database libraries in…

You might have seen aldjemy already but I thought I might mention it https://github.com/Deepwalker/aldjemy - let's us use SQLAlchemy queries in our django code without requiring redefining the models in an SQLAlchemy manner. It's easy to put a wrapper around it to convert SQLAlchemy results back into Django model instances. I'm exploring using Django Channels to send data to visualisation SPA's in realtime. https://c…

Yep I'm using Aldjemy as a bridge for now and it works great. I still really don't like having two completely different db layers in the same codebase. Whilst we're plugging the ecosystem/extensions, I also use Alembic which is amazing.

Re: Django 2.1 released

#34

Earlier quoted context omitted.

Not OP, but I've also been using Django for (more than) my whole career and I use React on the frontend. If you're curious about the frontend path I took, it was roughly: * jQuery with no framework * Backbone (for a couple years) * Backbone + Marionette (for a couple more years) * Angular (for about a week) * React (for the past few years)

Thanks for the input. Comments like these are insightful. What do you think of Vue.js?

Vue is a pleasure to build stuff in. It just seems to work well, especially with nice things like two-way binding out of the box.

Re: Django 2.1 released

#35
post #7

I've been working with Django for almost my whole career, since 1.1. It's a joy to use, and blows any other web framework I've used out of the water when it comes to actually just building stuff. Django is a fantastic boring[1] tool, and seeing boring updates like this is great. 1: http://mcfunley.com/choose-boring-technology

Yes! It is just like Rails. Almost as good! Is it Python 2 or Python 3?

https://wiki.python.org/moin/Python2orPython3

Re: Django 2.1 released

#36
post #6

Read-only model views are a great addition to the Django admin -- I've been watching that PR for a long time, glad to see it land. This will make it a lot easier to build internal admin dashboards that are safe to share with non-privileged users like support staff.

There were always ways to get read only in the admin. Just not nicely. It shouldn’t have been holding you back though.

Re: Django 2.1 released

#37
post #7

I've been working with Django for almost my whole career, since 1.1. It's a joy to use, and blows any other web framework I've used out of the water when it comes to actually just building stuff. Django is a fantastic boring[1] tool, and seeing boring updates like this is great. 1: http://mcfunley.com/choose-boring-technology

As a counter point, I tried to use Django for a data-visualisation project and ran into some problems. Everything is built on models, which are kind of activerecord pattern. Django has an inbuilt (and inferior) version of sqlalchemy, so that when you want to push sql past a certain point (define queries more complex than the api) you're pretty much stuck. Now you have codebase with two different database libraries in…

> Django kind of infects your code because it won't run without an initializarltion step

Most people using Django have built their apps as Django apps so this is a "non issue".

The worst way to use Django is to try and fight against the way it was built. For your case specifically, it's probably not a good option.

Re: Django 2.1 released

#38

Earlier quoted context omitted.

Not OP, but I've also been using Django for (more than) my whole career and I use React on the frontend. If you're curious about the frontend path I took, it was roughly: * jQuery with no framework * Backbone (for a couple years) * Backbone + Marionette (for a couple more years) * Angular (for about a week) * React (for the past few years)

When you moved to Angular and later to React did you have any jQuery heavy libraries? I'm using stuff like slickgrid[0], jquery-ui datepicker, json-editor[1] and wonder how I will drive these components from something like Angular or React? doh, quickly googled for the github links below and saw there now a slickgrid-es6[2] fork which I have not tried. But my question still stand: how do you drive jquery libs from ne…

I have encapsulated jQuery (including Bootstrap) plugins in AngularJS, React and Vue in the past. They all allow you to access a DOM node somehow.

Maybe it's frowned upon but I don't really like to use those (usually partial) Bootstrap re-implementation, especially in non-SPAs where you already have jQuery and/or Bootstrap.

Of course it's becoming less and less necessary.

Re: Django 2.1 released

#39
post #28

To django model users. Can you query keys inside a JSON datatype(pgsql)[0] from the ORM? For example in sqla you will do: records = db_session.query(Resource).filter( Resources.data["lastname"].astext == "Doe" ).all() with data being the json column and lastname a key in the column. [0]: https://stackoverflow.com/a/29975187

Sure you can. See the documentation: https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/f...

Thank for the quick reply. Now I need to understand how the "__" magic work; And I wonder what would django do if my key is "animal__breed".

Will it understand:

    Dog.objects.filter(data__animal__breed='collie')
But this is maybe questions I should rather ask on #django or stackoverflow.

Re: Django 2.1 released

#40
post #27

Earlier quoted context omitted.

As a counter point, I tried to use Django for a data-visualisation project and ran into some problems. Everything is built on models, which are kind of activerecord pattern. Django has an inbuilt (and inferior) version of sqlalchemy, so that when you want to push sql past a certain point (define queries more complex than the api) you're pretty much stuck. Now you have codebase with two different database libraries in…

The Django ORM has raw SQL escape hatches (either fully raw SQL database connections or model instance selections with SQL), and if you do need the SQLAlchemy query builder, slap in something like https://github.com/Deepwalker/aldjemy . As for the initialization stuff -- yes, that's true; whenever Django models are being imported, you do need to have had `django.setup()` called.

yea good point, I should have mentioned the raw SQL escape hatch, that also isn't an ideal solution. I went for aldjemy/instead them and in retrospect starting with something sqlalchemy native would have been cleaner.
Post reply on HN