Re: group by 3 fields

2017-02-27 Thread marcin . j . nowak
On Monday, February 27, 2017 at 3:52:38 AM UTC+1, larry@gmail.com wrote: > > [SQL] That is a language I > have worked in for over 20 years, and when I see a querying need that > is how I think, and then I see how can I do that with the ORM. > So I shouldn't give advices for you. We have s

Re: Multiple Databases

2017-02-27 Thread Luvpreet Singh
But dylan, I have written that Check1.objects.using('default').all() gives me error. On Mon, Feb 27, 2017 at 1:08 PM, Dylan Reinhold wrote: > It is going to use the database named default. > Checkout the doc on using mutiple DBs > https://docs.djangoproject.com/en/1.10/topics/db/multi-db/ > >

Re: Multiple Databases

2017-02-27 Thread ludovic coues
Have you checked your settings for typo ? 2017-02-27 10:02 GMT+01:00 Luvpreet Singh : > But dylan, I have written that > > Check1.objects.using('default').all() > > gives me error. > > On Mon, Feb 27, 2017 at 1:08 PM, Dylan Reinhold wrote: >> >> It is going to use the database named default. >> C

Re: Benefit of 'return Foo.objects.all()' in a ListView

2017-02-27 Thread Richard Jackson
Brilliant, thanks both, I've got it working in both ways! Much appreciated, Rich On Saturday, February 25, 2017 at 2:14:10 PM UTC, Melvyn Sopacua wrote: > > Hi Richard, > > > > Don't be discouraged to ask questions. It's what the list is for. > > > > Ludovic is right, you'd normally use the

What's the best way to create a reusable pagination template?

2017-02-27 Thread Frederik Creemers
The code for rendering pagination controls in my app is the same everywhere: {% if is_paginated %} {% if page_obj.has_previous %} Previous {% endif %} {% if page_obj.has_next %} Previous {% endif %}

Re: Flattening model relationships (in APIs)

2017-02-27 Thread Ankush Thakur
Marcin, that's exactly where I'm stuck! I know endpoints should never be 1:1 serialization of models, but I just don't know how to do that. I mean, I've been able to create endpoints like "/customers/1/payments/" where I use model relationships to generate JSON structures where Customer contains

Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
I'm not sure you want to read my answer, really... I've finally stopped using DRF and wrote own library which is focused on resources, linking and representations. I think you can do some customization in DRF, probably you ca declare custom serializer class, but this is a hard way, IMO. I like

Re: Flattening model relationships (in APIs)

2017-02-27 Thread Ankush Thakur
Hmmm. That's not an answer I wanted to hear, really, but I like it. I'm myself finding DRF too restrictive once you are past the effort-saving magic. Thank you. I might give it up as it's still early days in the project. Regards, Ankush Thakur On Mon, Feb 27, 2017 at 7:43 PM, wrote: > I'm not

Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
I was limited by DRF long days ago and I realized that it is not following REST architecutre. It does good job in automation in exposing models over http, but everything else is way complicated. But there were no problem mix both tools in one project. DRF was for "80%" of work and my lib for the

Re: Flattening model relationships (in APIs)

2017-02-27 Thread Ankush Thakur
I guess this is the library in question: https://github.com/marcinn/restosaur (took some effort to find it!). Thanks, if I decide to stick with the API-first approach, I'll use it. Either way, I've bookmarked it for future use. :-) Regards, Ankush Thakur On Mon, Feb 27, 2017 at 7:53 PM, wrote:

Re: Flattening model relationships (in APIs)

2017-02-27 Thread Xavier Ordoquy
Quick question. How will you handle the fields updates ? Like, what if you get an city_name="Bombay" and city_code="DEL" ? If you can set them as read-only, then using the source argument is the way to go. Alternatively, you can define a non model serializer and flatten the data before hand. You

Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
On Monday, February 27, 2017 at 3:30:11 PM UTC+1, Ankush Thakur wrote: > > I guess this is the library in question: > https://github.com/marcinn/restosaur (took some effort to find it!). > Thanks, if I decide to stick with the API-first approach, I'll use it. > Either way, I've bookmarked it f

Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
On Monday, February 27, 2017 at 3:38:34 PM UTC+1, Xavier Ordoquy wrote: > > > The more strict RESTfull way would be to use the several entry points and > use hyperlinks on them (though it would add some extra requests). > > This is just about representation. Nobody forces you to do such things.

Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
Wanna read something interesting? Look at http://t-code.pl/blog/2016/02/rest-misconceptions-0/ You will realize how many "antipatterns" are propagated in turorials on our World Wide Web, and where they're already implemented. On Monday, February 27, 2017 at 2:52:46 PM UTC+1, Ankush Thakur wrot

Re: Connecting to a database with logged in user credentials

2017-02-27 Thread konrad . perzyna
Thank you Melvyn. For now it's the best option we've found. W dniu czwartek, 23 lutego 2017 18:38:14 UTC+1 użytkownik Melvyn Sopacua napisał: > > Hi Konrad, > > On Thursday 23 February 2017 02:54:22 konrad@uni.lodz.pl > wrote: > > > > After starting the project, we've realised that db ro

Multiple Databases --- Migrations

2017-02-27 Thread Luvpreet Singh
I am using 2 postgres databases in my django app. 'newpostgre': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'new_postgre2', 'USER': 'tester', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', }, 'newpo

finding intersection of linestring and list of polygon

2017-02-27 Thread tazmainiac
Hi, I'm not sure if this is the right place for this or not - let me know if I should post somewhere else (GEOS mailing list). I have a large list (1000's) of polygons (django.contrib.gis.geos.Polygon), some of which overlap. What is the most efficient way to find which polygons intersect