Fwd: How to create orm query if data is exist or not ?

2023-02-23 Thread Prashanth Patelc
-- Forwarded message - From: Prashanth Patelc Date: Thu, Feb 23, 2023 at 5:11 PM Subject: How to create orm query if data is exist or not ? To: Hi all, How to create orm query with data exist or not ? How to check if approval_status Pending and Rejected with same user

How to create orm query if data is exist or not ?

2023-02-23 Thread Prashanth Patelc
Hi all, How to create orm query with data exist or not ? How to check if approval_status Pending and Rejected with same user contains from_date approval_status User 2023-01-20 - ApprovedNewUser 2023-01-12 - Rejected NewUser 2023-01

Orm query

2023-02-17 Thread Prashanth Patelc
Hi all, This is my model if model contain previous month dates I need to and store the data If user is new previous data is not available I need to store directly to db . How to write orm query? Attendance.object.filter(user=emp,date=enddate,crea_date=strdate) If dates is not available

Re: Django ORM query with joins

2020-03-30 Thread Anoop Thiparala
thanks that worked On Monday, March 30, 2020 at 7:49:07 PM UTC+5:30, Suraj Thapa FC wrote: > > Sorry its like this... > posts.objects.values('id', 'details', 'user__name' ) > > On Mon, 30 Mar 2020, 7:46 pm Suraj Thapa FC, > wrote: > >> posts.model.values('id', 'details', 'user__name' ) >> >> On

Re: Django ORM query with joins

2020-03-30 Thread Suraj Thapa FC
Sorry its like this... posts.objects.values('id', 'details', 'user__name' ) On Mon, 30 Mar 2020, 7:46 pm Suraj Thapa FC, wrote: > posts.model.values('id', 'details', 'user__name' ) > > On Mon, 30 Mar 2020, 5:26 pm Anoop Thiparala, > wrote: > >> I need help with a django query...I have two

Re: Django ORM query with joins

2020-03-30 Thread Suraj Thapa FC
posts.model.values('id', 'details', 'user__name' ) On Mon, 30 Mar 2020, 5:26 pm Anoop Thiparala, wrote: > I need help with a django query...I have two models > > 1)* POSTS* > ==>id > ==>details > ==>user(foreign key to user table) > > 2) *USER* > ==>id > ==>email > ==>name > > *SQL VERSION:*

Django ORM query with joins

2020-03-30 Thread Anoop Thiparala
I need help with a django query...I have two models 1)* POSTS* ==>id ==>details ==>user(foreign key to user table) 2) *USER* ==>id ==>email ==>name *SQL VERSION:* SELECT POSTS.ID, POSTS.DETAILS, USER.NAME FROM POSTS, USER WHERE POSTS.USER == USER.ID; I require these details in the same

RE: Database ORM query Help

2019-10-26 Thread dvdcedar
Thanks for the recommendation. The raw SQL method worked for me. Would be good to know how to accomplish this using the Django ORM query set. Basically I have a list of games, the user may choose to update the name for example and instead of the object being updated a new object is created

Re: Database ORM query Help

2019-10-25 Thread wd
I think you could consider using raw sql, https://docs.djangoproject.com/en/2.2/topics/db/sql/#executing-custom-sql-directly On Fri, Oct 25, 2019 at 7:56 PM Cheda me wrote: > Hey guys, > > I have worked out the SQL query I would like to implement but am currently > struggling to create the

Re: Database ORM query Help

2019-10-25 Thread Samiul Sk
Please post the code of Model and explain what do you want as Queryset? On Fri, 25 Oct 2019 at 17:26, Cheda me wrote: > Hey guys, > > I have worked out the SQL query I would like to implement but am currently > struggling to create the Django query. I have been attempting to use the >

Database ORM query Help

2019-10-25 Thread Cheda me
Hey guys, I have worked out the SQL query I would like to implement but am currently struggling to create the Django query. I have been attempting to use the .aggregate() & Max() methods but cant seem to get the right result. Any help is much appropriated. SELECT temp.* FROM item_detail temp

Re: Orm Query for this type of situation

2019-06-07 Thread Devender Kumar
Hi, On this question only I took some step deep and able to find out one part and need your help on the second half. This requires a good understanding of Django annotation and subquery features If you have this thank for reading and helping me in advance I am facing problem to filter calls on

Re: Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Account /Lead Model account_name contact m2m realtion contact Model name phone No calls Model caller no # person phone no who is calling agent no # person who is picking the call (CRM user) status timestamp duration calls model is populated with

Re: Orm Query for this type of situation

2019-06-06 Thread Chetan Ganji
Right now its an open ended question. If you post code for your models here, someone can help you. On Thu, Jun 6, 2019, 4:38 PM Devender Kumar wrote: > Hi, > I am working on CRM project and stuck with REPORTING part. > > I have Accounts , Lead , contact, Calls ,Concern modules > account/Lead

Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Hi, I am working on CRM project and stuck with REPORTING part. I have Accounts , Lead , contact, Calls ,Concern modules account/Lead can have multiple contacts contacts have multiple calls and concerns calls have different status like Incoming outgoing missed call etc Question I need to

Re: How to pass variable dates to a ORM query

2018-08-07 Thread Derek
You'll probably need to post some code snippets; what do these functions' signatures look like and how do they get called? On Tuesday, 7 August 2018 03:43:01 UTC+2, Gerald Brown wrote: > > I have a Django/Python function that creates a Reportab PDF file based on > the current date. Works GOOD.

How to pass variable dates to a ORM query

2018-08-06 Thread Gerald Brown
I have a Django/Python function that creates a Reportab PDF file based on the current date. Works GOOD. Now I want to pass any date to that function and have it create a PDF based on the new date. I tried creating another function that generates the date (yesterday) but I am not able to pass

How write advance Django ORM query

2017-07-21 Thread Foridur Kayes Shawon
https://stackoverflow.com/questions/45145257/how-write-advance-django-orm-query -- 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-user

Move python loop to ORM query and fix FieldError in ORM query using Conditional Expressions

2016-08-01 Thread Aditya Saraf
Hi, I have the following models defined: from django.db import models class IssuedCard(models.Model): plan_type = models.CharField(max_length=255)# This is actually a ForeignKey apn = models.CharField(max_length=255) # This is actually a Choice #

Please help me on generating the ORM query for given SQL query.

2016-01-13 Thread Pramod Bisht
I am unable to generate ORM query for given SQL query. I have posted this question on stackoverflow at http://stackoverflow.com/questions/34745199/django-orm-for-given-group-by-sql-query-with-aggregation-method-sum-and-count Please help me on that. Thanks in advance. -- You received

Re: ORM Query question

2015-07-13 Thread Joss Ingram
t;>>> event pages, each event page can be tagged (using taggit), and I want to >>>>> produce a list of distinct tags used in the events that belong to that >>>>> event index on the index itself. I'm using the Django CMS Wagtail, but I >>>>> guess this i

Re: ORM Query question

2015-07-13 Thread Avraham Serour
;> In my models I have an event index page type, which can have child >>>> event pages, each event page can be tagged (using taggit), and I want to >>>> produce a list of distinct tags used in the events that belong to that >>>> event index on the index itse

Re: ORM Query question

2015-07-13 Thread Joss Ingram
> pages, each event page can be tagged (using taggit), and I want to produce >>> a list of distinct tags used in the events that belong to that event index >>> on the index itself. I'm using the Django CMS Wagtail, but I guess this is >>> really a Django ORM query

Re: ORM Query question

2015-07-13 Thread Avraham Serour
jango CMS Wagtail, but I guess this is >> really a Django ORM query question. I''ve got some code as part of my model >> which is working but I don't think it's the most efficient way of doing >> this. Still trying unlearn doing things with SQL and learn how the same >&g

Re: ORM Query question

2015-07-13 Thread Joss Ingram
want to produce > a list of distinct tags used in the events that belong to that event index > on the index itself. I'm using the Django CMS Wagtail, but I guess this is > really a Django ORM query question. I''ve got some code as part of my model > which is working but I don't think

ORM Query question

2015-07-10 Thread Joss Ingram
this is really a Django ORM query question. I''ve got some code as part of my model which is working but I don't think it's the most efficient way of doing this. Still trying unlearn doing things with SQL and learn how the same thing should be done in Django. My code as part of the event index

Re: Django ORM - query help

2012-04-12 Thread Russell Keith-Magee
On Thursday, 12 April 2012 at 10:47 PM, Andre Terra wrote: > On Thu, Apr 12, 2012 at 10:01 AM, David (mailto:cthl...@gmail.com)> wrote: > > Log.objects.distinct('thing__id').order_by('thing__id', > > '-modified_on').select_related().filter(thing__deleted=0)[:20] > > > >

Re: Django ORM - query help

2012-04-12 Thread Andre Terra
On Thu, Apr 12, 2012 at 10:01 AM, David wrote: > Log.objects.distinct('thing__id').order_by('thing__id', > '-modified_on').select_related().filter(thing__deleted=0)[:20] > > By avoiding the use of values() I was able to then use the result as an > object and access everything

Re: Django ORM - query help

2012-04-12 Thread akaariai
On Apr 12, 4:01 pm, David wrote: > The above ORM statement however does not look as elegant to read as I have > come to expect from Django though. The resulting SQL doesn't seem too > shabby however. .distinct(fields) + .order_by() is pretty low level stuff - that is why it

Re: Django ORM - query help

2012-04-12 Thread David
Thank you akaariai That put me on the right track. Log.objects.distinct('thing__id').order_by('thing__id', '-modified_on').select_related().filter(thing__deleted=0)[:20] By avoiding the use of values() I was able to then use the result as an object and access everything I needed. The above

Re: Django ORM - query help

2012-04-12 Thread Jani Tiainen
12.4.2012 11:51, David kirjoitti: Hi Jani That was very helpful. Is there a way to include select_related into that query? or do I have to list every single field I would like to return using values()? last_deleted = ModificationLog.objects.values('thing__id', ' thing __prefix', ' thing

Re: Django ORM - query help

2012-04-12 Thread akaariai
On Apr 12, 11:52 am, David wrote: > > Hi Jani > > > That was very helpful. Is there a way to include select_related into that > > query? or do I have to list every single field I would like to return using > > values()? > > > last_deleted =

Re: Django ORM - query help

2012-04-12 Thread David
> > Hi Jani > > That was very helpful. Is there a way to include select_related into that > query? or do I have to list every single field I would like to return using > values()? > > last_deleted = ModificationLog.objects.values('thing__id', ' > thing__prefix', ' thing __first_name', '

Re: Django ORM - query help

2012-04-12 Thread David
Hi Jani That was very helpful. Is there a way to include select_related into that query? or do I have to list every single field I would like to return using values()? last_deleted = ModificationLog.objects.values('thing__id', ' thing __prefix', ' thing __first_name', ' thing__last_name', '

Re: Django ORM - query help

2012-04-11 Thread Jani Tiainen
11.4.2012 23:47, David kirjoitti: Thanks for your reply. I am grateful for your help. If you remember this question when you feel less sleepy I'd be very interested to see the inner join alternative :) Thanks again Well, after good night sleep I've some idea. Something like should do the

Re: Django ORM - query help

2012-04-11 Thread David
Thanks for your reply. I am grateful for your help. If you remember this question when you feel less sleepy I'd be very interested to see the inner join alternative :) Thanks again -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

Re: Django ORM - query help

2012-04-11 Thread Jani Tiainen
Hi, You're not doing anything wrong. The catch is that since "Thing" can exist without Log you will get outer join. If you want to get along with inner join, you should turn query around and start querying from Log model. I'm just too tired to think how it should be done right now... =) On

Django ORM - query help

2012-04-11 Thread David
class Log(models.Model): thing = models.ForeignKey(Thing) context = models.CharField(max_length=255) action = models.CharField(max_length=255) modifier = models.ForeignKey(User, limit_choices_to={'groups__in': [2]}) modified_on = models.DateTimeField(auto_now=True) class

Re: Django ORM query modelling question

2011-03-02 Thread Carsten Fuchs
Hi Jirka, Am 01.03.2011 21:44, schrieb Jirka Vejrazka: this does not seem to me like something you would be able to do using SQL (or Django ORM) only. I would guess that you'll have to write a bit of Python code that will walk through the entries and detect those that are different from

Re: Django ORM query modelling question

2011-03-01 Thread Jirka Vejrazka
Hi Carsten, this does not seem to me like something you would be able to do using SQL (or Django ORM) only. I would guess that you'll have to write a bit of Python code that will walk through the entries and detect those that are different from "previous" Cheers Jirka -- You received

Django ORM query modelling question

2011-03-01 Thread Carsten Fuchs
Dear Django list, after a very good start with Django and it's excellent documentation, I've come now across a problem that neither my SQL nor my Django knowledge is sufficient to solve, so I'd like to ask for your kind help. The (simplified) Django model is class Erfasst(models.Model):

Re: ORM Query question

2010-04-12 Thread Tim Shaffer
Or, using range: MyModel.objects.filter( Q(a__range=(1,5)) | Q(b__range=(20,70)) ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email

Re: ORM Query question

2010-04-12 Thread Tim Shaffer
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects MyModel.objects.filter( ( Q(a__gt=1) & Q(a__lt=5) ) | ( Q(b__gt=20) & Q(b__lt=70) ) ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: ORM Query question

2010-04-12 Thread rebus_
On 13 April 2010 01:09, zweb wrote: > how do i do this kind of condition in django orm filter: > > ( 1 < a < 5)  or ( 20 < b < 70) > > select * from table where (a between 1 and 5) or (b between 20 and 70) > > -- > You received this message because you are subscribed to

ORM Query question

2010-04-12 Thread zweb
how do i do this kind of condition in django orm filter: ( 1 < a < 5) or ( 20 < b < 70) select * from table where (a between 1 and 5) or (b between 20 and 70) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Missing features on Django ORM (Query Cache, Persistant Connexion/Connexion Pool)

2009-03-25 Thread Malcolm Tredinnick
On Wed, 2009-03-25 at 16:01 -0700, Kedare wrote: > Hello, > I'm here because i need to know if the following feature will be > included in the futures releases of django (if yes, what release ?) or > why are they missing ? > -- REAL Query cache (like in ruby on rails), very useful if you have >

Re: Missing features on Django ORM (Query Cache, Persistant Connexion/Connexion Pool)

2009-03-25 Thread Kedare
>> To my knowledge most of the core >> developers feel that a full identity mapper isn't appropriate for Django. Why ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Missing features on Django ORM (Query Cache, Persistant Connexion/Connexion Pool)

2009-03-25 Thread Alex Gaynor
On Wed, Mar 25, 2009 at 7:01 PM, Kedare wrote: > > Hello, > I'm here because i need to know if the following feature will be > included in the futures releases of django (if yes, what release ?) or > why are they missing ? > -- REAL Query cache (like in ruby on rails), very

Missing features on Django ORM (Query Cache, Persistant Connexion/Connexion Pool)

2009-03-25 Thread Kedare
Hello, I'm here because i need to know if the following feature will be included in the futures releases of django (if yes, what release ?) or why are they missing ? -- REAL Query cache (like in ruby on rails), very useful if you have redundant SQL request (like multiple recursive requests by

Re: Optimizing my ORM query

2009-03-06 Thread Jeff Gentry
Sorry for the self-followup, but I got the right bits of extra. My actual case was a bit more complicated than my example below (it involved a fourth model), but it's working now - and much quicker than w/ the IN directive. Thanks. On Fri, 6 Mar 2009, Jeff Gentry wrote: > On Fri, 6 Mar 2009,

Re: Optimizing my ORM query

2009-03-06 Thread Sebastian Bauer
W dniu 06.03.2009 20:06, Jeff Gentry pisze: > On Fri, 6 Mar 2009, Malcolm Tredinnick wrote: > >>> Bob.objects.filter(foo=myFoo).filter(blah__in=myBlahs) >>> >> Seems like the best (and obvious) way to me. >> > > Gotcha. > > >> Yes it does. As written, your models have no

Re: Optimizing my ORM query

2009-03-06 Thread Jeff Gentry
On Fri, 6 Mar 2009, Malcolm Tredinnick wrote: > > Bob.objects.filter(foo=myFoo).filter(blah__in=myBlahs) > Seems like the best (and obvious) way to me. Gotcha. > Yes it does. As written, your models have no ordering requirements. That > complete lack of constraint is preserved perfectly. :-)

Re: Optimizing my ORM query

2009-03-06 Thread Sebastian Bauer
W dniu 06.03.2009 01:24, Malcolm Tredinnick pisze: > On Thu, 2009-03-05 at 18:48 -0500, Jeff Gentry wrote: > >> Suppose I have three models (in pseudocode): >> >> class Foo: >> asdf = models.CharField() >> >> class Blah: >> qwerty = models.CharField() >> >> class Bob: >> foo =

Re: Optimizing my ORM query

2009-03-05 Thread Malcolm Tredinnick
On Thu, 2009-03-05 at 18:48 -0500, Jeff Gentry wrote: > Suppose I have three models (in pseudocode): > > class Foo: >asdf = models.CharField() > > class Blah: >qwerty = models.CharField() > > class Bob: >foo = models.ForeignKey(Foo) >blah = models.ForeignKey(Blah) > > Given a

Optimizing my ORM query

2009-03-05 Thread Jeff Gentry
Suppose I have three models (in pseudocode): class Foo: asdf = models.CharField() class Blah: qwerty = models.CharField() class Bob: foo = models.ForeignKey(Foo) blah = models.ForeignKey(Blah) Given a Foo and a list of Blahs (where the length of the list might be very small (0-10)