Re: django queryset - Get the data particular to current year only

2022-04-04 Thread Trippy Samurai
Thanks for the reply Brother but it's already solved On Sunday, 3 April 2022 at 12:05:39 UTC+5:30 sutharl...@gmail.com wrote: > I think this is related to your query > https://stackoverflow.com/a/28101722/8882295 > > On Thu, 31 Mar 2022 at 11:22, Trippy Samurai > wrote: > >> >>

Re: django queryset - Get the data particular to current year only

2022-04-02 Thread Lalit Suthar
I think this is related to your query https://stackoverflow.com/a/28101722/8882295 On Thu, 31 Mar 2022 at 11:22, Trippy Samurai wrote: > > > > I have my query written to get some thing from database and display on my > website that query is get

Re: Django Queryset

2020-12-13 Thread Jorge Gimeno
On Sun, Dec 13, 2020 at 7:21 PM MAMADOU KANTE wrote: > Hi to everybody; > I have been trying to deploy an app through heroku for the past 7 days but > whenever I reach the final stage I receive a rejection message. > The message tells me the module "skbuild" was not imported or I should > upgrad

Re: Django Queryset

2020-12-13 Thread MAMADOU KANTE
Hi to everybody; I have been trying to deploy an app through heroku for the past 7 days but whenever I reach the final stage I receive a rejection message. The message tells me the module "skbuild" was not imported or I should upgrade my pip version. But when I check through the terminal I find th

Re: Django Queryset

2020-11-04 Thread Walter Randazzo
Hi there. Did you try datatable Regards, El mié., 4 nov. 2020 8:30 a. m., lada...@gmail.com escribió: > Hello, Django Users please I need your help and it is urgent, > > I have this code: > *permit_cy = Permit.objects.values(* > > *'info__date_of_transaction__year', > 'info_

Re: Django queryset filtering

2020-10-11 Thread Dvs Khamele
Hi do you hire contract based python/django freelancer? We can help you in this and related tasks at fair prices. Reply or send email to divy...@pythonmate.com Best Regards, Divyesh Khamele, Pythonmate On Thu, 25 Jun 2020, 3:55 am mtp...@gmail.com, wrote: > I have a queryset that returns all th

Re: Django queryset filtering

2020-10-06 Thread mtp...@gmail.com
Thanks guys this was very useful On Friday, June 26, 2020 at 6:27:23 PM UTC+3 Dan Madere wrote: > I'd make two queries. One to see which businesses currently have active > licenses, then a second to get the expired licenses, excluding the > businesses from the first query. Here's some example

Re: Django queryset filtering

2020-06-26 Thread Dan Madere
I'd make two queries. One to see which businesses currently have active licenses, then a second to get the expired licenses, excluding the businesses from the first query. Here's some example code, assuming the LicenseIssue model has a "business" foreign key field: *active_business_ids = Licen

Re: Django queryset filtering

2020-06-25 Thread Oleg Kishenkov
Hello, use a filtering chain, a refined queryset is itself a queryset so you can filter it further. Also, Django has extensive lookup support in its filtering methods. Let's assume LicenseIssue is related to Business as many to one (it is probably the case): class Business(models.Model): name

Re: Django queryset result and mysql query are wrong after updating from 3.0.2 to 3.0.3

2020-02-19 Thread mohamed alisaleh...@gmail.com
بتاريخ الأربعاء، 19 فبراير، 2020 10:51:53 م UTC+3، كتب Ricardo H: > Hi Simon,  > > > It was ok on 2.2.6, only on 3.0.3 it fails. > > > I use BigIntegerField because I use it for some calculations after that, but > even if I try with DurationField it doens't assert right. > > > Definitely mus

Re: Django queryset result and mysql query are wrong after updating from 3.0.2 to 3.0.3

2020-02-19 Thread Simon Charette
Hello Ricardo, I suggest you follow these docs to submit your bug report and link to this thread. https://docs.djangoproject.com/en/3.0/internals/contributing/bugs-and-features/#reporting-bugs I'd mention that the issue is also present if you use `output_field=DurationField` as BigIntegerField

Re: Django queryset result and mysql query are wrong after updating from 3.0.2 to 3.0.3

2020-02-19 Thread Ricardo H
Hi Simon, It was ok on 2.2.6, only on 3.0.3 it fails. I use BigIntegerField because I use it for some calculations after that, but even if I try with DurationField it doens't assert right. Definitely must be caused by this patch, if I can't find another solution, where and how should I report

Re: Django queryset result and mysql query are wrong after updating from 3.0.2 to 3.0.3

2020-02-19 Thread Simon Charette
Hello Ricardo, This could be a regression caused by a patch addressing a regression in 3.0.3[0]. Did you also notice this behaviour on Django 2.2.x or was this project started from Django 3.0? >From what I can see though I find it strange that the ExpressionWrapper of end_total_time have an o

Re: Django Queryset for Multiple set

2019-03-13 Thread Chetan Ganji
Hi Vaibhav, I think this would do what you want. Make sure too call the objects on the model name ( Modelname ) ;-) systems = ['windows', 'unix'] variable = Modelname.objects.filter(clientname=cname, clienttype__in=systems, errorcode='20') Regards, Chetan Ganji +91-900-483-4183 ganji.che...

Re: Django Queryset for Multiple set

2019-03-13 Thread Krishnasagar Subhedarpage
You could do using django ORM query expressions. Refer below link: https://docs.djangoproject.com/en/2.1/ref/models/expressions/ Regards, Krishnasagar Subhedarpage On Wed, 13 Mar 2019 at 17:14, Vaibhav Mishra wrote: > Hi All, > > I am trying to achieve below , > > variable = object.filter(cl

Re: Django queryset returning corrupted value

2017-10-09 Thread Web Architect
Hi Antonis, Thanks for your response. You are right, The issue wasn't in MySQL or even Django ORM. We were using Cachalot (http://django-cachalot.readthedocs.io/en/latest/) for query caching which was causing the issue. Disabling cachalot fixed the issue. Would need to look more into query cac

Re: Django queryset returning corrupted value

2017-10-08 Thread Antonis Christofides
Hi, this is very strange of course. I doubt it has anything to do with MySQL, because even if MySQL had done something wrong and had returned a long in place of a string, the Django ORM should have caught that and raised an error earlier. So the problem must be in Django. (But of course with such

Re: Django queryset returning corrupted value

2017-10-07 Thread Web Architect
Hi Antonis, Thanks for your response: Following is the model: from treebeard.mp_tree import MP_Node @python_2_unicode_compatible [docs] class AbstractCategory(MP_N

Re: Django queryset returning corrupted value

2017-10-06 Thread Antonis Christofides
Hi, could you show the code that defines the slugfield, the queryset that is returning the wrong value, full error message and traceback (if available), and the version of your OS and RDBMS? It doesn't matter if the problem is more general; let's focus on one specific manifestation of it. Reg

Re: Django queryset High CPU Usage

2017-03-14 Thread Vijay Khemlani
"In the above, the CPU was hitting almost 100% and was taking almost a second" So, your query was resolved in a second, that's normal, also the spike in cpu usage because... the cpu is working... Your problem seems to be in your for loop for a in As: retrieve other related data from associa

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Daniel, Thanks for the suggestion. Would look into django-import-export. Thanks. On Saturday, March 11, 2017 at 6:29:57 PM UTC+5:30, Daniel Hepper wrote: > > In additions to the suggestions you already received from others, have a > look at django-import-export. It allows you to easily expor

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Camilo, Thanks for your suggestion. Would certainly look for solutions outside Django if Django cannot suffice. But was trying to find something with Django since the web part was in Django and for easy of development. We are already using Celery Extensively but then high Resource Usage is n

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
On Sunday, March 12, 2017 at 4:53:25 AM UTC+5:30, James Schneider wrote: > > > > On Mar 11, 2017 12:01 PM, "Vijay Khemlani" > wrote: > > Am I the only one who thinks that generating a report over a set of > just 10.000 records could be done in 10 - 20 secs unless there are > some serious computa

Re: Django queryset High CPU Usage

2017-03-13 Thread Web Architect
Hi Vjiay, My apologies if the scenario is not clear. Following are the details: Lets say there is a Model A (with fields, foreignkeys and ManyToMany relationships with other models). There are 10k records for A. Lets say following is the pseudo code for the report: As = A.objects.all() for a

Re: Django queryset High CPU Usage

2017-03-11 Thread Melvyn Sopacua
On Saturday 11 March 2017 21:29:10 Vijay Khemlani wrote: > "But the CPU usage and time taken are high" <- I'm assuming high > enough to be problematic for OP. > > I'm seriously not following. Why are people suggesting reporting and > export software when OP hasn't even described the problem in det

Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
"But the CPU usage and time taken are high" <- I'm assuming high enough to be problematic for OP. I'm seriously not following. Why are people suggesting reporting and export software when OP hasn't even described the problem in detail. It's not even clear whether the high cpu and time taken are du

Re: Django queryset High CPU Usage

2017-03-11 Thread James Schneider
On Mar 11, 2017 12:01 PM, "Vijay Khemlani" wrote: Am I the only one who thinks that generating a report over a set of just 10.000 records could be done in 10 - 20 secs unless there are some serious computations going on with that data? For a report I have to query around 200.000 records, with ag

Re: Django queryset High CPU Usage

2017-03-11 Thread Vijay Khemlani
Am I the only one who thinks that generating a report over a set of just 10.000 records could be done in 10 - 20 secs unless there are some serious computations going on with that data? For a report I have to query around 200.000 records, with aggregations, and it takes less than a minute using th

Re: Django queryset High CPU Usage

2017-03-11 Thread Daniel Hepper
In additions to the suggestions you already received from others, have a look at django-import-export. It allows you to easily export data in various formats. Hope that helps, Daniel Hepper https://consideratecode.com On Friday, March 10, 2017 at 12:06:13 PM UTC+1, Web Architect wrote: > > Hi J

Re: Django queryset High CPU Usage

2017-03-11 Thread Camilo Torres
Hi. You can probably use another web framework for that report, or even rethink your architecture and put the report creation outside Django and the web server without Django ORM. You may be interested in evaluating Celery and Django Celery. You can create a separate task outside Django to cre

Re: Django queryset High CPU Usage

2017-03-10 Thread Vijay Khemlani
This is what you said "There is a Model A with 1 records. Just a simple queryset - A.objects.all() is resulting in CPU hitting almost 100%. Is there a way to optimize this? But why would such a query result in high CPU Usage?" By that, I assume that you opened a shell and executed "A.objects

Re: Django queryset High CPU Usage

2017-03-10 Thread Web Architect
Hi, Thanks for your response. Well, its not just the queryset but when the query triggered by an if condition or a for loop - thats what I meant. I was doing some basic performance check as well while working on the report generation - I observed the issue. There's no manager other than the d

Re: Django queryset High CPU Usage

2017-03-10 Thread Web Architect
Hi Melvyn, Thanks for your response. We are using the Celery for all tasks which could be done offline or separately. Report generation is one of it. We trigger the task from Browser but the report creation is run via Celery which when completed sends the csv filepath to the browser to be down

Re: Django queryset High CPU Usage

2017-03-10 Thread Vijay Khemlani
There is something wrong in your setup I can query a 400.000 item table in less than a second with the typical "Model.objects.all()". Django does not convert all of the entries into objects just by that query. You don't have any managers, or anything that can result in a side-effect beyond the qu

Re: Django queryset High CPU Usage

2017-03-10 Thread Web Architect
Hi James, Thanks for the clarification. Much appreciated. Will follow your points for the reporting part considering the overheads in ORM. Thanks, On Friday, March 10, 2017 at 4:55:35 PM UTC+5:30, James Bennett wrote: > > If all you need is to export data from your database (with or without >

Re: Django queryset High CPU Usage

2017-03-10 Thread Melvyn Sopacua
On Friday 10 March 2017 03:06:12 Web Architect wrote: > Hi James, > > Thanks for your response. Melvyn also posed a similar point of not > loading the whole records. > > But all the records are needed for reporting purposes - where the data > is read from the DB and a csv report is created. I am

Re: Django queryset High CPU Usage

2017-03-10 Thread James Bennett
If all you need is to export data from your database (with or without transforming it along the way) to a CSV, using the normal QuerySet methods is probably the wrong approach; you don't need model objects to do that. Some options include: * Use raw SQL to query for the data and push it to CSV (al

Re: Django queryset High CPU Usage

2017-03-10 Thread Web Architect
Hi James, Thanks for your response. Melvyn also posed a similar point of not loading the whole records. But all the records are needed for reporting purposes - where the data is read from the DB and a csv report is created. I am not quite an expert on Django but I am not sure if there is a be

Re: Django queryset High CPU Usage

2017-03-10 Thread James Schneider
On Mar 9, 2017 9:37 PM, "Web Architect" wrote: Would like to further add - the python CPU Usage is hitting almost 100 %. When I run a Select * query on Mysql, its quite fast and CPU is normal. I am not sure if anything more needs to be done in Django. Ironically, things being done in Django is

Re: Django queryset High CPU Usage

2017-03-10 Thread Melvyn Sopacua
On Thursday 09 March 2017 21:25:51 Web Architect wrote: > I am a bit perplexed by this and not sure what the solution is. > Following is the scenario: > > There is a Model A with 1 records. Just a simple queryset - > A.objects.all() is resulting in CPU hitting almost 100%. What's the problem

Re: Django queryset High CPU Usage

2017-03-09 Thread Web Architect
Would like to further add - the python CPU Usage is hitting almost 100 %. When I run a Select * query on Mysql, its quite fast and CPU is normal. I am not sure if anything more needs to be done in Django. On Friday, March 10, 2017 at 10:55:51 AM UTC+5:30, Web Architect wrote: > > Hi, > > I am

Re: django queryset/annotate get extra column

2016-05-20 Thread stunaz
Wonderfull (ps :sorry, I should have put the model) On Friday, May 20, 2016 at 2:40:33 AM UTC-4, James Schneider wrote: > > On Wed, May 18, 2016 at 9:54 PM, stunaz > > wrote: > >> Hi, >> I would like to write the following query using django orm. >> >> select * , >> (select image_url from blog_im

Re: django queryset/annotate get extra column

2016-05-19 Thread James Schneider
On Wed, May 18, 2016 at 9:54 PM, stunaz wrote: > Hi, > I would like to write the following query using django orm. > > select * , > (select image_url from blog_image bi where bi.blog_id = b.id and bi. > principal=1) as blog_main_imange > from blog b > > > Any idea, how to write the queryset ? >

Re: Django Queryset with filtering on reverse foreign key failing

2014-07-31 Thread Anthony
Could not resolve tblconfigagentgroupmembers. I've resolved the issue now though. I moved the model to models.py from the models_auto.py file and was then getting some validation errors mostly missing id fields(just set primary keys on the generated models) and now it's working as expected. On F

Re: Django Queryset with filtering on reverse foreign key failing

2014-07-31 Thread cmawebsite
What does the FieldError say? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to dja

Re: Django queryset csv encode

2014-05-26 Thread hito koto
Hi, WongoBongo, Thanks 2014年5月26日月曜日 18時39分20秒 UTC+9 WongoBongo: > > If you want all the user_name's in Staff as UTF-8: > > staff = Staff.objects.all() > staff_list = [s.user_name.encode('utf-8') for s in staff] > > I'm not familiar with the encoding you mentioned in your last message. Try > i

Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
If you want all the user_name's in Staff as UTF-8: staff = Staff.objects.all() staff_list = [s.user_name.encode('utf-8') for s in staff] I'm not familiar with the encoding you mentioned in your last message. Try it. K On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote: > > Hi, > > this

Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
Okay, I re-read your first post. You said that you wanted to get a UTF-8 string. name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name', flat=True)] This variable 'name' now contains a UTF-8 encoded string in a list-like object. Python 2.7.6 (default, Jan

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I have this: >>> x = name >>> import locale >>> locale.getdefaultlocale()[1] 'UTF8' >>> print x ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] after i try this : >>> name ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] >>> type(name) Traceback (most recent call last): File "",

Re: Django queryset csv encode

2014-05-25 Thread WongoBongo
Python 2.7.6 (default, Jan 13 2014, 04:26:18) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = u'\u54c8\u65af\u671d\u9b6f' >>> print(x) 哈斯朝魯 >>> import locale >>> locale.getdefaultlocale()[1] 'UTF-8' >>> K On Sunday, May

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I'm try tha's but results: >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8') u'\u54c8\u65af\u671d\u9b6f' 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo: > > Python 3.4.0 (default, Mar 20 2014, 12:50:31) > [GCC 4.0.1 (Apple Inc. build 5493)] on darwin > Type "help", "copyri

Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Python 3.4.0 (default, Mar 20 2014, 12:50:31) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8') '哈斯朝魯' K On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I7m try that's this time not the error but output the ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo: > > Try > > name = [name.encode("utf8") for name in Staff.objects.filter(id = > 3).values_list('user_name', *flat=True*)] > > The other

Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Try name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name', *flat=True*)] The other returns one-tuples in a list https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list K On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote: > > Hi, >

Re: Django queryset 'in' operator fails on first call

2013-04-13 Thread Peter of the Norse
On Apr 10, 2013, at 7:44 AM, bradley griffiths wrote: > Corss posted from stack overflow > > When using the 'in' operator on a queryset, the first time the call is made > it fails. > > from django.db import models > > > class Category(models.Model): > name = models.CharField(max_length=1

Re: Django queryset 'in' operator on two querysets fails on first call

2013-04-10 Thread Tom Evans
On Wed, Apr 10, 2013 at 2:26 PM, bradley griffiths wrote: > Cross posted from: stack overflow. > > When using the 'in' operator on two querysets, the first time the call is > made it fails. > > … > > print category_list # [, ] > print other_cats # [] > print category_list[0] in other_cats # False

Re: Django queryset 'in' operator on two querysets fails on first call

2013-04-10 Thread carlos
maybe need read de docu https://docs.djangoproject.com/en/1.5/ref/models/querysets/#select-related Cheers On Wed, Apr 10, 2013 at 7:26 AM, bradley griffiths < bradley.griffi...@gmail.com> wrote: > Cross posted from: stack > overflow

Re: Django queryset custom manager - refresh caching

2010-12-20 Thread LaundroMat
On Dec 20, 2:23 pm, Daniel Roseman wrote: > On Monday, December 20, 2010 11:03:10 AM UTC, LaundroMat wrote: > > > Hi - > > > Django seems to be caching data that I query through a custom method on a > > model. I've tried to describe the issue over at SO ( > >http://stackoverflow.com/questions/40

Re: Django queryset custom manager - refresh caching

2010-12-20 Thread LaundroMat
On Dec 20, 2:23 pm, Daniel Roseman wrote: > On Monday, December 20, 2010 11:03:10 AM UTC, LaundroMat wrote: > > > Hi - > > > Django seems to be caching data that I query through a custom method on a > > model. I've tried to describe the issue over at SO ( > >http://stackoverflow.com/questions/40

Re: Django queryset custom manager - refresh caching

2010-12-20 Thread Daniel Roseman
On Monday, December 20, 2010 11:03:10 AM UTC, LaundroMat wrote: > > Hi - > > Django seems to be caching data that I query through a custom method on a > model. I've tried to describe the issue over at SO ( > http://stackoverflow.com/questions/4010317/django-queryset-custom-manager-refresh-caching)

Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
My models are defined like this: class Problem(models.Model): title = models.CharField('Title', max_length = 100) question = models.TextField('Question') class Submission(models.Model): user = models.ForeignKey(User) problem = models.ForeignKey(Problem) solution = models.CharK

Re: django queryset get only one result for one column pair

2010-08-14 Thread Nick
http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct Distinct() may be what you're looking for to returns distinct values for each problem. Or, petter yet, you could use .latest() So Submission.objects.all().latest('problem').distinct() http://www.djangoproject.com/documentation/

Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
On Aug 14, 5:57 pm, Kenneth Gonsalves wrote: > On Sat, 2010-08-14 at 05:45 -0700, Rohan Jain wrote: > > I have a field 'submission' which has a 'user' and a 'problem'. > > How can i get a django queryset search result which will give a list > > of only one result per user-problem pair. > > does

Re: django queryset get only one result for one column pair

2010-08-14 Thread Rohan Jain
Actually there may be many submissions with a user-problem pair but i want to list only the last one per user - problem pair. Like: let p1 be two problems , u1, u2 be two users and s1,s2 two submissions by user u1 on problem and s3,s4 by u2. so i want to get a queryset with only the last submissi

Re: django queryset get only one result for one column pair

2010-08-14 Thread Kenneth Gonsalves
On Sat, 2010-08-14 at 05:45 -0700, Rohan Jain wrote: > I have a field 'submission' which has a 'user' and a 'problem'. > How can i get a django queryset search result which will give a list > of only one result per user-problem pair. does your model not have a unique_together for user and problem

Re: django queryset based on when data created

2009-08-06 Thread krylatij
You can use ordering by primary key (id by default) because it increments by every insert. So newly created rows in db will have greater id than others. In most cases it can be enough. --~--~-~--~~~---~--~~ You received this message because you are subscribed to th

Re: django queryset based on when data created

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 21:41 -0700, Joru wrote: > Everytime I edit some data, the data order in queryset changed into > the newest edited > Is it posible to get queryset that ordered based when the data created > without having to add creation date for sorting purpose The order results are returne