Re: Django Query

2021-10-05 Thread Adeyemi Deji
You can read up the documentation regarding MPTT, sure to be useful. https://django-mptt.readthedocs.io/en/latest On Tuesday, October 5, 2021 at 10:05:42 AM UTC+2 eugenet...@gmail.com wrote: > Is there any one with a typical example or tutorial (of Django mptt) that > tolks on the similar

Re: Django Query

2021-10-05 Thread Eugene TUYIZERE
Is there any one with a typical example or tutorial (of Django mptt) that tolks on the similar issue as mine and share with me? regards, On Tue, 5 Oct 2021 at 01:00, Sebastian Jung wrote: > Hello Eugene, > > I think that django mptt can Store and display such a tree. > > Regards > > Eugene

Re: Django Query

2021-10-04 Thread Sebastian Jung
Hello Eugene, I think that django mptt can Store and display such a tree. Regards Eugene TUYIZERE schrieb am Mo., 4. Okt. 2021, 20:29: > Team, > > Assume you have 3 tables PROVINCES, DISTRICTS, and SECTORS and you have > Province, District and Sector field names respectively in each table. >

Django Query

2021-10-04 Thread Eugene TUYIZERE
Team, Assume you have 3 tables PROVINCES, DISTRICTS, and SECTORS and you have Province, District and Sector field names respectively in each table. How can you display in the Django template the following table? Province District Sectors A A1 A11 A12 A2 A21 A22 A3 A31 A32 Any assistance will

Re: use of annotate in django query

2021-07-26 Thread V. J
1) from django.core.serializers.json import DjangoJSONEncoder >>>>>>>>> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder) >>>>>>>>> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com >>>>>>>>>

Re: Django Query vs SQL query

2021-06-15 Thread Nikeet NA
y > project_id. But I am confused about how to construct the query. I think of > the SQL as below > > *Select * from Projects where Projects.id = Staffs.projects_id * > > I want to transform this query into a django query. > > Assist please > > -- > *Eugene

Django Query vs SQL query

2021-06-15 Thread Eugene TUYIZERE
of the SQL as below *Select * from Projects where Projects.id = Staffs.projects_id * I want to transform this query into a django query. Assist please -- *Eugene* -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

Re: use of annotate in django query

2021-06-05 Thread Lalit Suthar
m >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Dear Suthar, >>>>>>>>> >>>>>>>>> Your idea works well , but I want now to display the result on >>>>>>>>>

Re: use of annotate in django query

2021-06-05 Thread Eugene TUYIZERE
>>> but Am getting the error message: >>>>>>>> >>>>>>>> Exception Value: >>>>>>>> >>>>>>>> Object of type date is not JSON serializable >>>>>>>> >>>>

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
eqChart(request): >>>>>>> aa = Customer_Requests.objects.values("arrival_date").annotate( >>>>>>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1] >>>>>>> print(aa) >>>&g

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
tesb = list() >>>>>> sumdata = list() >>>>>> for dd in aa: >>>>>> datesb.append(dd['arrival_date']) >>>>>> sumdata.append(dd['num_req']) >>>>>> arriva_days = { >>>>>> 'name': 'Datess', >>>&

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
or': 'green' >>>>> } >>>>> chart3 = { >>>>> 'chart': {'type': 'column'}, >>>>> 'title': {'text': 'Previous statistics'}, >>>>> 'xAxis': {'datesb': datesb}, >>>>> 'series': [arriva_days] >>>>>

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
gt; return render(request,'summarizedchart.html',{'chart3': dump3}) >>>> >>>> Please once again >>>> >>>> regards, >>>> >>>> >>>> >>>> On Thu, 3 Jun 2021 at 09:00, lalit

Re: use of annotate in django query

2021-06-03 Thread Lalit Suthar
;>> >>> On Thu, 3 Jun 2021 at 09:00, lalit suthar wrote: >>> >>>> this will do >>>> >>>> Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")).order_by(&qu

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
TC+5:30 abubak...@gmail.com wrote: >>> >>>> to display last 30 records you can write your code like this: >>>> Customer_Requests.objects.all()[-30] >>>> >>>> On Thu, Jun 3, 2021 at 10:51 AM Eugene TUYIZERE >>>> wrote: >>>>

Re: use of annotate in django query

2021-06-03 Thread lalit suthar
AM Eugene TUYIZERE >>> wrote: >>> >>>> Dear Latit, >>>> >>>> Thank you very much. Now how can I display 30 last records? Regardless >>>> of how many records I may have ! Just the last 30 records! >>>> >>>>

Re: use of annotate in django query

2021-06-03 Thread Eugene TUYIZERE
t;> of how many records I may have ! Just the last 30 records! >>> >>> Thank you >>> >>> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar wrote: >>> >>>> > in brief, I want to transform this query in django query >>>> this w

Re: use of annotate in django query

2021-06-03 Thread lalit suthar
! >> >> Thank you >> >> On Thu, 3 Jun 2021 at 06:51, Lalit Suthar wrote: >> >>> > in brief, I want to transform this query in django query >>> this will be equivalent to this query in django >>> >>> Customer_Request

Re: use of annotate in django query

2021-06-03 Thread DJANGO DEVELOPER
the last 30 records! > > Thank you > > On Thu, 3 Jun 2021 at 06:51, Lalit Suthar > wrote: > >> > in brief, I want to transform this query in django query >> this will be equivalent to this query in django >> >> Customer_Requests.objects.va

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Latit, Thank you very much. Now how can I display 30 last records? Regardless of how many records I may have ! Just the last 30 records! Thank you On Thu, 3 Jun 2021 at 06:51, Lalit Suthar wrote: > > in brief, I want to transform this query in django query > this will be e

Re: use of annotate in django query

2021-06-02 Thread Lalit Suthar
> in brief, I want to transform this query in django query this will be equivalent to this query in django Customer_Requests.objects.values("arrival_date").annotate(num_req=Count("request_name")) On Thu, 3 Jun 2021 at 02:02, Eugene TUYIZERE wrote: > in brief, I wa

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
in brief, I want to transform this query in django query [image: image.png] On Wed, 2 Jun 2021 at 21:56, Eugene TUYIZERE wrote: > Dear Sebatian, > > This is what I get: > > SELECT `crms_customer_requests`.`arrival_date`, > COUNT(`crms_customer_requests`.`request_name

Re: use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Sebatian, This is what I get: SELECT `crms_customer_requests`.`arrival_date`, COUNT(`crms_customer_requests`.`request_name`) AS `count` FROM `crms_customer_requests` WHERE `crms_customer_requests`.`arrival_date` >= 2021-05-03 GROUP BY `crms_customer_requests`.`arrival_date` ORDER BY NULL

Re: use of annotate in django query

2021-06-02 Thread Sebastian Jung
Hi Eugene, Please make Print(report.query) then you get SQL querys and Most of time i get an Idea what's wrong Regards Eugene TUYIZERE schrieb am Mi., 2. Juni 2021, 21:41: > Dear Team, > > I need help. I am working on a project where one of the tables is about > requests. I want to have a

use of annotate in django query

2021-06-02 Thread Eugene TUYIZERE
Dear Team, I need help. I am working on a project where one of the tables is about requests. I want to have a report of the number of requests on each day in the last 30 days, something like this: [image: image.png]I I used the code below just before displaying on the chart but the code gives me

Re: PostgreSQL Django Query

2021-01-07 Thread gabriela...@gmail.com
Sachin: I don't understand the reason you bring 2 million records. Why you don't do that witht REACT? So there is not recharge the browser every time request data from server. El jueves, 7 de enero de 2021 a las 11:13:23 UTC-3, sachin...@gmail.com escribió: > I am using Python Django and

PostgreSQL Django Query

2021-01-07 Thread Sachin Kumar
I am using Python Django and PostgreSQL to build our report app. I am using below mention query to find some details. the query mention below is running fine in PostgreSQL command line and giving result in 2 sc for 2 million cards but when i i am try the same in Django application it is taking

Re: Django query with few data(1,000-3,000) takes too long(1min) to load

2020-02-07 Thread Stephen J. Butler
You've got a lot of foreign key fields where the fetch is being deferred until template render time, and it being done individually for each row instead of in bulk. I think if you added this attribute to your ListView subclass you'd see better performance: queryset =

Django query with few data(1,000-3,000) takes too long(1min) to load

2020-02-07 Thread Eric Kiser
I created an app with the following details: Hosting: PythonAnywhere Database: SQLite and MySQL Problem: When I load the data in a table it takes minutes to load it. My data hasn't even reached a million its just a few thousands. How I did it: models.py class Outgoing(models.Model):

Re: Make a Django query filter at runtime

2020-01-11 Thread Derek
There is a long discussion about "not equals" here: https://stackoverflow.com/questions/687295/how-do-i-do-a-not-equal-in-django-queryset-filtering I am sure you can adapt one of the suggestions there for your specific needs. On Friday, 10 January 2020 14:35:48 UTC+2, Ezequias Rocha wrote: > >

Re: Make a Django query filter at runtime

2020-01-10 Thread Ezequias Rocha
Hi Alex I could do almost all query but not the "not equals" could you give me some tip to add this operator to my object? I am doing the following way: if (operador == 'equals'): d[realname] = value elif (operador == greather than'): d[realname + '__gt'] = value

Re: Make a Django query filter at runtime

2020-01-09 Thread Ezequias Rocha
It worked well. Many thanks. On Wednesday, January 8, 2020 at 10:08:18 PM UTC-3, Alex Conselvan de Oliveira wrote: > > Hi Ezequias, > > You could use a dict: > > data = { > 'name': 'John', > 'age': 42, > } > > model.filter(**data) > > Best Regards! > > Em qua., 8 de jan. de 2020 às 18:09,

Re: Make a Django query filter at runtime

2020-01-09 Thread Ezequias Rocha
Thank you very much Alex and Shaheed, but if I want to use the *>, >= <, <=* how do do that? On Wednesday, January 8, 2020 at 10:08:18 PM UTC-3, Alex Conselvan de Oliveira wrote: > > Hi Ezequias, > > You could use a dict: > > data = { > 'name': 'John', > 'age': 42, > } > >

Re: Make a Django query filter at runtime

2020-01-08 Thread Alex Conselvan de Oliveira
Hi Ezequias, You could use a dict: data = { 'name': 'John', 'age': 42, } model.filter(**data) Best Regards! Em qua., 8 de jan. de 2020 às 18:09, Ezequias Rocha < ezequias.ro...@gmail.com> escreveu: > Hi everyone > > I am in a doubt about creating django filters dynamically. > > All you

Re: Make a Django query filter at runtime

2020-01-08 Thread Shaheed Haque
On Wed, 8 Jan 2020 at 20:09, Ezequias Rocha wrote: > Hi everyone > > I am in a doubt about creating django filters dynamically. > > All you know a filter is made by using the parameters like: > > model.filter(name='John', age=42) > > But if I can't type all fields and values at design time but

Make a Django query filter at runtime

2020-01-08 Thread Ezequias Rocha
Hi everyone I am in a doubt about creating django filters dynamically. All you know a filter is made by using the parameters like: model.filter(name='John', age=42) But if I can't type all fields and values at design time but at runtime how to do that? Best regards Ezequias -- You received

Re: Django Query

2019-11-12 Thread Eng. Medson Naftal
Visit this link https://simpleisbetterthancomplex.com/tutorial/2018/01/18/how-to-implement-multiple-user-types-with-django.html On Tue, Nov 12, 2019, 18:20 Suraj Thapa FC wrote: > You can simply do this with a single login > > On Tue, 12 Nov 2019, 6:59 pm Deepak Singh, > wrote: > >> I have a

Re: Django Query

2019-11-12 Thread Suraj Thapa FC
You can simply do this with a single login On Tue, 12 Nov 2019, 6:59 pm Deepak Singh, wrote: > I have a survey form for students and teachers. Questions are different > for students and teachers, so I want to provide them with different login. > How do I create different login pages in Django

Django Query

2019-11-12 Thread Deepak Singh
I have a survey form for students and teachers. Questions are different for students and teachers, so I want to provide them with different login. How do I create different login pages in Django that redirect to different pages? And how can I store the students and teachers username and password

Django query set

2019-09-15 Thread Suraj Thapa FC
https://hastebin.com/powupucitu.sql Can anyone convert this into queryset... -- 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

How to make the mock object iterable ['TypeError: 'Mock' object is not iterable'] Need to Mock the django query that is iterating through for loop

2019-05-08 Thread Shashank Gupta
I am trying to mock the below django query object : 1.) if MyModel.objects.filter(data='some_data').exists(): then 2.) for row in MyModel.objects.filter(ListId=id): I am trying to test below django query inside my method. def my_method(some_parameter

Re: django Query filter

2019-04-04 Thread Nikolay Smirnov
The global POST variable allows you to access the data sent with the POST method by* input name*. See more info https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data . Your html: First name: Last name: On Wednesday, 3 April 2019

Re: django Query filter

2019-04-04 Thread Nikolay Smirnov
The global POST variable allows you to access the data sent with the POST method by* input name*. See more info https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_and_retrieving_form_data . Your html: First name: Last name: On Thursday, 4 April 2019

Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
Thanks for the help, this is showing only one value in dictionary at a time . There is no fault here but i have a question can we run multiple search query in same page with different id ? And it shows that error even now On Wed, Apr 3, 2019 at 5:56 PM dvij parekh wrote: > > seems like search1

Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
Thanks..I'll search for that but i think its not related to the query, its related to two search i have used in one post request On Wed, Apr 3, 2019 at 5:57 PM Guru Murthy wrote: > Hi abhineet baranwal, > You have to use q(id__in=search) instead q(id__icontains=search) ..search > more about how

Re: django Query filter

2019-04-04 Thread Abhineet Baranwal
I edited it as you suggested but it is giving another error like 'method' object is not subscriptable On Wed, Apr 3, 2019 at 10:24 PM Nikolay Smirnov wrote: > Your request.POST does not contain "search1". > Do so search1 = request.POST.get('search1') > > Example: > def viewstr(request): >

Re: django Query filter

2019-04-03 Thread Nikolay Smirnov
Your request.POST does not contain "search1". Do so search1 = request.POST.get('search1') Example: def viewstr(request): views = create_store.objects.all() brn = Prod_Brand.objects.all() mi = '' if request.method == 'POST': search1 = request.POST.get('search1') if

Re: django Query filter

2019-04-03 Thread Guru Murthy
Hi abhineet baranwal, You have to use q(id__in=search) instead q(id__icontains=search) ..search more about how to use in query in django and 1 thing you are not getting correct post value of searc1 On Wed, 3 Apr, 2019, 5:31 PM Abhineet Baranwal, < suabhineetbaran...@gmail.com> wrote: > Thanks

Re: django Query filter

2019-04-03 Thread dvij parekh
seems like search1 key is containg multi value dictionary and you are checking it with == which is for single value after *search1 = request.POST['search1'] * put *print(* *search1* *)* *return "hello"* and comment code remaining below ,check terminal it will show you how many value you

Re: django Query filter

2019-04-03 Thread Abhineet Baranwal
Thanks for your efforts, But i didn't get it can you please elaborate your answer? On Wed, Apr 3, 2019 at 5:16 PM Guru Murthy wrote: > Hi Abhijeet baranwal, > I think you are adding contains is not correct query listing you have to > use in query instead > > > On Wed, 3 Apr, 2019, 5:02 PM

Re: django Query filter

2019-04-03 Thread Guru Murthy
Hi Abhijeet baranwal, I think you are adding contains is not correct query listing you have to use in query instead On Wed, 3 Apr, 2019, 5:02 PM Abhineet Baranwal, < suabhineetbaran...@gmail.com> wrote: > > *this is my views file which creates an error like >

django Query filter

2019-04-03 Thread Abhineet Baranwal
*this is my views file which creates an error like django.utils.datastructures.MultiValueDictKeyError: 'search1' . Can anyone tell me where i go wrong?* *def viewstr(request):* *views = create_store.objects.all()brn = Prod_Brand.objects.all()mi = ''if

Re: how to convert django query objects in blow formal json

2018-08-09 Thread arvind yadav
ye Thanks Regards Arvind Kumar Yadav Mobile:9873451821 Software Engineer (python/Django) Email: developer.arvind2...@gmail.com *Arvind Yadav On Linkedin* On Wed, Aug 8, 2018 at 4:26 PM, SACHIN

Re: how to convert django query objects in blow formal json

2018-08-08 Thread SACHIN CHAVAN
use Django rest framework, user serializers for converting queryset into the JSON format -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: how to convert django query objects in blow formal json

2018-08-08 Thread SACHIN CHAVAN
Did you mean to say Django queryset? right? On Wed, Aug 8, 2018 at 4:04 PM arvind yadav wrote: > > > *how to convert django query objects in blow formal js*on > > > { > title:{ > text: " march 2018 " > }, > data: [{ >

how to convert django query objects in blow formal json

2018-08-08 Thread arvind yadav
*how to convert django query objects in blow formal js*on { title:{ text: " march 2018 " }, data: [{ type: "column", dataPoints: [ { label: "sv", y: 3}, ] },

how to django query objects parse in json below format please help me

2018-08-08 Thread arvind yadav
my Quey objects is jsonquery = PartDetails.objects.all() { title:{ text: " march 2018 " ### is time }, data: [{ type: "column", dataPoints: [ { label: "sv", y: 3}, ] }, { type: "line",

Re: Django query not returning all objects

2016-08-19 Thread Constantine Covtushenko
Hi Koonal, Sorry for not exact suggestion. I hope that combination of `annotate` and `values` will be helpful, see this link for more detailed explanation . Pleas try something like following: cases =

Re: Django query not returning all objects

2016-08-19 Thread Simon Charette
For reference there's a Django ticket to suggest using this technique. Cheers, Simon [1] https://code.djangoproject.com/ticket/19842 Le jeudi 18 août 2016 02:20:34 UTC-4, Todor Velichkov a écrit : > > Another solution would be to annotate min/max deadline date and order by > the annotation.

Re: Django query not returning all objects

2016-08-18 Thread Koonal Bharadwaj
Hi Todor, I have implemented something similar: cases = HeartFlowCase.objects.all().annotate(Count('hf_id', distinct=True)) I also tried your suggestion and both seem to produce the same results. The number of duplicates is minimized but not removed entirely. Also the same problem when

Re: Django query not returning all objects

2016-08-18 Thread Koonal Bharadwaj
Hi Constantine, Thanks for the quick reply. No luck with distinct. I tried that before (cases = cases.distinct() ), right after the order_by but it seems to have no effect, returning multiple duplicates. On Wednesday, August 17, 2016 at 9:59:19 PM UTC-7, Constantine Covtushenko wrote: > >

Re: Django query not returning all objects

2016-08-18 Thread Todor Velichkov
Another solution would be to annotate min/max deadline date and order by the annotation. Something like: cases = HeartFlowCase.objects.all().annotate(min_deadline=Min( 'data__deadline')).order_by('min_deadline') On Thursday, August 18, 2016 at 7:59:19 AM UTC+3, Constantine Covtushenko wrote:

Re: Django query not returning all objects

2016-08-17 Thread Constantine Covtushenko
Hi Koonal, As said in django doc you can use `distinct()` to remove duplicated rows from first query. I believe with this your pagination should works as expected. Regards, On Thu, Aug 18, 2016 at 2:58 AM, Koonal

Django query not returning all objects

2016-08-17 Thread Koonal Bharadwaj
Hello, The issue: When trying to order_by on a related model duplicate entries are created. I solved this with an OrderedSet that is applied after paginating ( http://code.activestate.com/recipes/576694/). However, when I try to paginate the queryset, all the results are not returned. It's

Re: Date() in Django query

2016-06-15 Thread Simon Charette
gt;> Cheers, >> Simon >> >> [1] >> https://docs.djangoproject.com/en/1.10/ref/models/database-functions/#django.db.models.functions.datetime.TruncDate >> [2] >> https://docs.djangoproject.com/en/1.9/ref/models/expressions/#func-expressions >> >> Le mard

Re: Date() in Django query

2016-06-15 Thread Galil
tabase-functions/#django.db.models.functions.datetime.TruncDate > [2] > https://docs.djangoproject.com/en/1.9/ref/models/expressions/#func-expressions > > Le mardi 14 juin 2016 09:52:34 UTC-4, Galil a écrit : >> >> Hi, >> >> How can I convert this SQL query

Re: Date() in Django query

2016-06-14 Thread Simon Charette
/#func-expressions Le mardi 14 juin 2016 09:52:34 UTC-4, Galil a écrit : > > Hi, > > How can I convert this SQL query into a Django query? > > SELECT DATE(JoinTime) FROM table > > Please keep in mind that JoinTime is in datetime format and I want it to > be date. >

Re: Date() in Django query

2016-06-14 Thread Stephen J. Butler
Assuming "obj" is an instance of a Model class for this table: obj.jointime.date() On Tue, Jun 14, 2016 at 8:52 AM, Galil <il...@ajenta.net> wrote: > Hi, > > How can I convert this SQL query into a Django query? > > SELECT DATE(JoinTime) FROM table > &

Date() in Django query

2016-06-14 Thread Galil
Hi, How can I convert this SQL query into a Django query? SELECT DATE(JoinTime) FROM table Please keep in mind that JoinTime is in datetime format and I want it to be date. Thanks -- You received this message because you are subscribed to the Google Groups "Django users&q

Re: Django query returns nothing for legacy databse

2016-06-09 Thread Remco Gerlich
Do you have a database router set up to tell Django which models are stored in which database? Greetings, Remco Gerlich On Thu, Jun 9, 2016 at 2:13 PM, Galil wrote: > Hello, > > I am using two databses for my Django app and one of them is an existing > MySQL database: > >

Re: Django query returns nothing for legacy databse

2016-06-09 Thread Gagaro
Hi, You should select the database you want to use: Calls.objects.using('calls').all() See https://docs.djangoproject.com/en/1.9/topics/db/multi-db/#manually-selecting-a-database On Thursday, 9 June 2016 14:13:22 UTC+2, Galil wrote: > > Hello, > > I am using two databses for my Django app and

Django query returns nothing for legacy databse

2016-06-09 Thread Galil
Hello, I am using two databses for my Django app and one of them is an existing MySQL database: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'users.sqlite3'), }, 'calls': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'portal2',

Re: Performance difference between django query and stored procedure (MySQL)?

2016-01-08 Thread Sergiy Khohlov
orl...@gmail.com> wrote: > I was wondering what the performance hit on using a django query over a > stored procedure would be? I realize that django doesn't support stored > procedures so that's why I was hoping to avoid using stored procedures. > However, then the query won't be

Performance difference between django query and stored procedure (MySQL)?

2016-01-08 Thread Maor Levy
I was wondering what the performance hit on using a django query over a stored procedure would be? I realize that django doesn't support stored procedures so that's why I was hoping to avoid using stored procedures. However, then the query won't be compiled in the db and the calculations

Re: django query, order results such that th128 > th99

2015-09-28 Thread Gergely Polonkai
Hello, what you want to achieve is called "natural order sorting" which is not built into any common SQL implementation I know. You have to do it manually from code, or, if you have to do pagination, add a sorting column that is numeric (and indexed). Best, Gergely On 28 Sep 2015 08:42,

django query, order results such that th128 > th99

2015-09-28 Thread gintare
Is it possible to order the query result strings in such a way that th128 string would be first comparing to th99. The query results contains 128 items in format: "th"+number. For instance, th1, th2, ...th80, ..th99, th100, th128. Than i order results, they go in the following order, th1,

Re: Django Query to get max rating

2015-03-18 Thread Filipe Ximenes
>From what I could understand, you are trying to fetch all the top ratings for each question in a group, correct? The problem is that this query: top_rated_list = Ratings.objects.get(rating = max_rating) ​ is returning more than one rating instance. "get" queries are supposed to return a single

Django Query to get max rating

2015-03-18 Thread Yadnesh Patil
My model structure is like this: class Group(models.Model): u_id= models.ForeignKey(User) group_name = models.CharField(max_length=50,unique=True) def __str__(self): # __unicode__ on Python 2 return self.group_name + " " + self.org_nam

Re: Django Query Set

2015-02-11 Thread C. Kirby
I'm sure someone can help you, but you need to post some more information to get useful support. Please post the models that you are dealing with, as well as maybe an example of the result you are trying to get. On Wednesday, February 11, 2015 at 8:20:59 AM UTC-6, Ajay M wrote: > > I'm on a

Django Query Set

2015-02-11 Thread Ajay M
I'm on a Django Project, I'm stuck with this situation. I've 3 Models, records,users and towns. Records are posted by users who belongs to towns. User may be a mobile user or a web user. Primary key of users is a foreign key in records, primary key of towns is a foreign key in users. I need to

Re: Django query in DetailView

2014-10-30 Thread Collin Anderson
Hello, I _think_ your code looks right to me, though the query / or_query code is confusing. Print statements could be helpful there to be sure it's actually filtering something. Does this code work? def searchcandidate(request): query_string = request.GET.get('q', '').strip()

Django query in DetailView

2014-10-29 Thread Ronaldo Bahia
*This question is also in http://stackoverflow.com/questions/26635406/django-query-in-detailview I have DetailVIew wich returns a list of related objects (m2m throught). It works just fine! But I need to search for objects'names and it is returning all objects instead of only the related ones

Re: Django Query Data

2014-05-05 Thread C. Kirby
The reason you are getting a dictionary in return is because the call to values() returns a ValueQuerySet, which is an iterable of dictionaries ( https://docs.djangoproject.com/en/dev/ref/models/querysets/#values) In order to get a list of tee colors (eg ['Blue',Green','Red']) you should use a

Django Query Data

2014-05-04 Thread Brendan Edwards
Hi, I have just started learning Django (been flip flopping between meteor and django, cant decide which to use..) and I am fairly new to web development in general. Basically, I have a query where I am using the code "teecolor =

How to convert SQL Complex QUERY to django QUERY

2014-03-18 Thread Shoaib Ijaz
I am trying to convert sql query to django query but failed to do this, can anyone help me select id,name,round(value::numeric,2) as value, st_transform(geometry, 3857) as geometry from net_rest where state_id in (1,2) and name = 'height' union (select d.id

Re: Django query from database

2013-10-11 Thread Leonardo Giordani
Ok, I think I got the point. So, correct me if I didn't get it right, you have to get users which have first_name, last_name, or other fields equal to the words in your list B. This can be accomplished by looking at each field for each keyword. I would also compile a dictionary keeping reference

Re: Django query from database

2013-10-11 Thread Kamal Kaur
On Fri, Oct 11, 2013 at 6:43 PM, Leonardo Giordani wrote: > Sorry, I forgot the User part of your question. > > Let me understand the exact relationship between codes, words and users: do > those words or codes come from a form? Or are saved in the DB for each user?

Re: Django query from database

2013-10-11 Thread Leonardo Giordani
Sorry, I forgot the User part of your question. Let me understand the exact relationship between codes, words and users: do those words or codes come from a form? Or are saved in the DB for each user? I ask this because I want to understand if you are trying to get a relationship that already

Re: Django query from database

2013-10-11 Thread Kamal Kaur
On Fri, Oct 11, 2013 at 4:06 PM, Leonardo Giordani wrote: > I think that you have to perform a query for each Code, extracting the list > of Word matching that Code and then merging all the lists. Exactly! > Since I don't know your models, I'll give you some general

Re: Django query from database

2013-10-11 Thread Leonardo Giordani
I think that you have to perform a query for each Code, extracting the list of Word matching that Code and then merging all the lists. Since I don't know your models, I'll give you some general code, let me know if you understand how to implement it exactly on your models. Assuming that the

Django query from database

2013-10-11 Thread Kamal Kaur
Hello there, Hope you are doing well :) I have a problem regarding querying a list from two tables, the procedure goes like: Considering two tables from mysql database: 1. UserProfile table, with complete client details: First name, Last name, Address, email id, Contact number etc. 2.

Django query Advanced

2013-09-26 Thread Hélio Miranda
I am trying a query like this: result = json.dumps([a.get_json() for a in Player.objects.filter((Q(name=namepost) | Q(surname="Coimbra")))]) return HttpResponse (result, content_type = 'application / json') But it gives me the following error: Not a query object: (AND: ('surname',

django query

2013-08-17 Thread Robin Lery
Hello, I have a model like this: class Forum(models.Model): question = models.CharField(max_length=150) body = models.TextField() pub_date = models.DateTimeField(default=datetime.now) image = models.ImageField(upload_to=get_upload_file_name) creator = models.ForeignKey(User,

how to use MySQL YEARWEEK() function in django query?

2013-06-11 Thread Bertrand Grégoire
Hello, I'd like to the use the MySQL function YEARWEEK (and INTERVAL) to aggregate timed data, as it looks more efficient than a double date comparison (start-date;end-date). How would it best be done with django? My current SQL query, that counts various types of mails exchanged over a

how to use MySQL function in django query?

2013-06-11 Thread Bertrand Grégoire
Hello, I'd like to use some MySQL function in a query from django, because the YEARWEEK() & INTERVAL constructs of mysql are interesting to me for efficiently aggregating entries per week. Is there any way to include it in the Select of the django query... or do I have to resort to raw()

Re: Django - Query

2013-05-05 Thread Siddharth Ghumre
Hi, get the length of object by using len(movieObject) if len(movieObject)==1: #you can get along with get query if len(movieObject)>1: #use filter query and access each element by using for loop for i in movieObject: -Siddharth On Mon, May 6, 2013 at 1:54 AM, Shawn

Re: Django - Query

2013-05-05 Thread Shawn Milochik
On Sun, May 5, 2013 at 3:29 PM, Hélio Miranda wrote: > How do I get the two? > > -- > > Use .filter() instead of .get(). -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

Re: Django - Query

2013-05-05 Thread Aljoša Mohorović
something like: try: # code except Movie.DoesNotExist: # code except Movie.MultipleObjectsReturned: # code except: # catch all exceptions check http://docs.python.org/2/tutorial/errors.html#handling-exceptions Aljosa -- You received this message because you are subscribed to

Re: Django - Query

2013-05-05 Thread Hélio Miranda
How do I get the two? -- 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

Re: Django - Query

2013-05-05 Thread Aljoša Mohorović
you're catching DoesNotExist but should also catch MultipleObjectsReturned check https://docs.djangoproject.com/en/1.5/ref/exceptions/ Aljosa -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

  1   2   >