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 issu

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 TU

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. > >

Re: Django Query vs SQL query

2021-06-15 Thread Nikeet NA
use the related name on the staff model for project field with __ lookup as in class Staff(models.Model): . . project = foreignkey relationship (related_name='staffs') SO the query would be Projects.objects.filter(staffs__project_id=F('pk')) On Tuesday, 15 June 2021 at

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 = Outgoing.objects.select_relate

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 su

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 th

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 13:33:20

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 09:43

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 k

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): > vi

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 s

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 for

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 hav

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 Abhi

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.utils.datastructures.MultiV

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 = HeartFlowCase.objects.v

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. Som

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 applyi

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: > > H

Re: Django query not returning all objects

2016-08-17 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 Bharadwaj

Re: Django query returns nothing for legacy databse

2016-06-10 Thread Galil
@Gagaro, thanks! That worked for me! @Remco Gerlich, no I don't have a database router as what I am doing now is very simple But thank you for you answer anyway! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group an

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: > > DATABASES = { > 'defa

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

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

2015-09-27 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, "gintare"

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 r

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 Dja

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() found_en

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 va

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? Actually I have to search for

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 exi

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 code, let me know > if you un

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 CodeTa

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 Milochi

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 emails from it, send an

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 th

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 django-user

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 emai

Re: Django - Query

2013-05-05 Thread Hélio Miranda
I'm doing this But it gives me the following error: MultipleObjectsReturned at / 2 items returned, instead of 1 What am I doing wrong? Código (Python): try: movieObject = Movie.objects.get(MovieTitle=line['Movie Name (EN)']) except Movie.DoesNotExist: movieObject=Movie()

Re: Django - Query

2013-05-04 Thread cingusoft
: django-users@googlegroups.com Date: Sat, 4 May 2013 06:49:48 To: Reply-To: django-users@googlegroups.com Subject: Re: Django - Query That was it, but now I'm the problem is that, I wonder if there is a movie on BD, but there insert. I am trying as follows, but I do not get: And it gives m

Re: Django - Query

2013-05-04 Thread Hélio Miranda
That was it, but now I'm the problem is that, I wonder if there is a movie on BD, but there insert. I am trying as follows, but I do not get: And it gives me the following error: Movie matching query does not exist. The film is not clear ... Does anyone know what I'm doing wrong? Código (Python)

Re: Django - Query

2013-05-03 Thread Larry Martell
On Fri, May 3, 2013 at 3:22 PM, Hélio Miranda wrote: > I am trying a query in Django for mongodb, but I do not get it. > I'm doing this: > > Código (Python): > post = Solution.objects.get({'SolutionName':'MEGLES'}) > print post > > But it prints the following: Solution object > > What am I doing w

Re: django query question

2009-02-27 Thread Alex Gaynor
On Fri, Feb 27, 2009 at 2:40 PM, Bobby Roberts wrote: > > hi all. I have a situation where I have two tables, auctions and > bids. I need to do a subquery as such: > > select distinct id from auctions_auction where Active=1 and id IN > (select distinct AuctionId_id from auctions_bid where Bidde

Re: django query database

2008-12-14 Thread bruno desthuilliers
On 14 déc, 19:03, "Alfredo Alessandrini" wrote: > > Sorry but your question is not clear. Are 'min_rating' and > > 'max_rating' fields of the game object ? If yes: > > Yes > > It's better: > > game_list = game.objects.filter(Q(max_rating__gt = player.rating) & > Q(min_rating__lt = player.rating))

Re: django query database

2008-12-14 Thread Alfredo Alessandrini
> Sorry but your question is not clear. Are 'min_rating' and > 'max_rating' fields of the game object ? If yes: Yes It's better: game_list = game.objects.filter(Q(max_rating__gt = player.rating) & Q(min_rating__lt = player.rating)) or game_list = game.objects.exclude(min_rating__gt=player.ra

Re: django query database

2008-12-14 Thread bruno desthuilliers
On 14 déc, 00:46, "Alfredo Alessandrini" wrote: > Hi, > > It's possible call a query with max or min value?: > > like this: > > game_list = game.objects.filter(Q(max_rating > player.rating) & > Q(min_rating < player.rating)) Sorry but your question is not clear. Are 'min_rating' and 'max_rating'

Re: django query database

2008-12-14 Thread Alfredo Alessandrini
> On Sun, 2008-12-14 at 00:46 +0100, Alfredo Alessandrini wrote: >> Hi, >> >> It's possible call a query with max or min value?: >> >> like this: >> >> game_list = game.objects.filter(Q(max_rating > player.rating) & >> Q(min_rating < player.rating)) > > Not yet. Search the archives of this list fo

Re: django query database

2008-12-13 Thread Malcolm Tredinnick
On Sun, 2008-12-14 at 00:46 +0100, Alfredo Alessandrini wrote: > Hi, > > It's possible call a query with max or min value?: > > like this: > > game_list = game.objects.filter(Q(max_rating > player.rating) & > Q(min_rating < player.rating)) Not yet. Search the archives of this list for the wor

Re: django query API help

2008-11-24 Thread Alex Koshelev
Values gets onli fields names [1]. Try this: results = Article.objects.filter(qset).values('published_at') [1]: http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields On Mon, Nov 24, 2008 at 13:16, kele <[EMAIL PROTECTED]> wrote: > > hi all, > > i have some codes like these: