Re: [Question] Django 2 - how to sum values based on filter and group by Year-Month

2018-07-27 Thread Melvyn Sopacua
On vrijdag 27 juli 2018 04:25:56 CEST Charles Sartori wrote: > I need to Sum() the values filtering it with > 1 - sum(values) where date < first day of the month > 2 - sum(values) where date < last day of the month > > Expected result(something like that): > [ > {'year-month': '2018-01'}, {'sum_

Re: Optimizing Prefetch for Postgres IN Limit

2018-07-27 Thread Jason
well, prefetch explicitly does joining in python, as in the docs https://docs.djangoproject.com/en/2.0/ref/models/querysets/#django.db.models.query.QuerySet.prefetch_related prefetch_related, on the other hand, does a separate lookup for each relationship, and does the ‘joining’ in Python. sinc

Re: Change the default route of a view

2018-07-27 Thread Jason
you can probably do this with overriding a few things, but for me, your use case has some major problems. you're effectively breaking away from the basics of REST. If you want to implement some sort of non-sequential identifiers for users/resources, use UUIDs. Any token passed in the headers

Re: learn dijango

2018-07-27 Thread Rajdeep Bharati
Hi Arul, You should be comfortable with the basics of Python and HTML to get started with Django. Head over to: https://docs.python.org/3/tutorial/ and follow that tutorial for python, also practice coding in a text editor and the python interpreter. After you are through with that, then you can

Re: avoiding import-time queries

2018-07-27 Thread clavierplayer
I've been experimenting with it and it seems to be working pretty well. Thank you, Julio! On Thursday, July 26, 2018 at 2:28:18 PM UTC-4, Julio Biason wrote: > > Hi Clarvierplayer, > > Dunno if that's a best practice, but I'd add a module in the same app with > functions to retrieve the informat

Re: Change the default route of a view

2018-07-27 Thread Fernando Miranda
I think I understood about the rest, the right one to edit for example would be to have the route of type PUT passing the token OAuth2 in the route and there I look for the user owner of the token? Or the user ID and check if the authenticated user is the same as the last ID? Em sexta-feira, 27

Re: Change the default route of a view

2018-07-27 Thread Andréas Kühne
Hi Fernando, In DRF even with token authentication you will be able to get the currently logged in user via the user object on the request. So request.user will be the user doing the request. If you for example want to have an endpoint that is for the current user you could just check the request

Re: Optimizing Prefetch for Postgres IN Limit

2018-07-27 Thread Simon Charette
There's two open tickets to work around this issue. https://code.djangoproject.com/ticket/25464 which allows passing queryset override to be used for retrieval and another one that I can't currently find that allows specifying that a subquery should be used instead of a an IN clause. Simon L

Re: Change the default route of a view

2018-07-27 Thread Fernando Miranda
Hi Andrea, So, I'm getting the user that way, I'm in doubt is how to mount the routes to an account view, where you have the retrieve, update and delete of the current user. Em sexta-feira, 27 de julho de 2018 12:23:24 UTC-3, Andréas Kühne escreveu: > > Hi Fernando, > > In DRF even with token a

Re: Optimizing Prefetch for Postgres IN Limit

2018-07-27 Thread Ram J
Hi Xof, I realized what you meant regd the optimizer and understood why my query was doing a full table scan. The issue was that column through which I prefetching has a lot of NULLs so we have a partial index on NOT NULL and the optimizer is getting fooled by that. Adding a IS NOT NULL in the sam

Re: User Authenticated in Gunicorn and Daphne

2018-07-27 Thread Andrew Godwin
You can configure Nginx to route to different backends based on path - put your Nginx proxy_pass settings inside a "location" block. You can find examples on Stack Overflow - for example: https://stackoverflow.com/questions/13399252/nginx-reverse-proxy-to-multiple-backends Andrew On Tue, Jul 24,

Re: Problem with sending django channels event from models

2018-07-27 Thread Andrew Godwin
You need to post the full traceback, not just the last section. I suspect what you are doing is calling model methods directly in an async function, but I can't confirm that without a full traceback. Andrew On Thu, Jul 26, 2018 at 1:10 PM luan fonceca wrote: > Hello, i'm trying to implement a "