Django2.0.7 generate SQL query function is wrong(REGEXP_LIKE).

2018-07-25 Thread Hiroyuki Yamashita
My name is Hiroyuki Yamashia. Create SQL query function is wrong by Django2.0.7. I using MariaDB and using "__regex". Django2.0.7 is generate this SQL query. SELECT `scanner_tmpresponse_07`.`id` FROM `scanner_tmpresponse_07` WHERE (`scanner_tmpresponse_07`.`audit_history

Re: Djnago Python (INNER JOIN Query Or JOIN Query)

2018-06-26 Thread Jason
Yadav wrote: > > Hello Everyone, > > > *I want to make INNER JOIN Query Or JOIN Query with "Video" and "* > *Thumbimages**". Kindly let me know.* > > *Below my Models:-* > > *from __future__ import unicode_literals* > *from django.db import

Djnago Python (INNER JOIN Query Or JOIN Query)

2018-06-26 Thread Pravin Yadav
Hello Everyone, *I want to make INNER JOIN Query Or JOIN Query with "Video" and "* *Thumbimages**". Kindly let me know.* *Below my Models:-* *from __future__ import unicode_literals* *from django.db import models* *from django.utils import timezone* *from django.template.d

Re: Query about django

2018-06-18 Thread Artur Gontijo
It is just what it describes in the end of the sentence: "user authentication, content administration, site maps, RSS feeds, and many more tasks" Examples for user authentication: user registration, login, logout, etc. On Monday, June 18, 2018 at 3:01:55 PM UTC-3, Navjit Kaur wrote: > >

Re: Query about django

2018-06-18 Thread Andréas Kühne
Common web application tasks :-) Seriously though - Django makes it easy to do things that you may want to do with a web application, for example: * Handle forms for adding / updating items in a database * Competent ORM. * User authentication / authorization * Simple admin interface * Handle

Query about django

2018-06-18 Thread Navjit Kaur
Hello, I have recently started learning about Django. Before I start making projects using Django I just wished to read about it first. So, I visited to the Django website. https://www.djangoproject.com/start/overview/ At there, in the various features of Django there is one feature that is

RE: How to include a Where clause for each query on django?

2018-06-14 Thread Matthew Pava
MyModel: objects = MyCustomerManager() From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Fellipe Henrique Sent: Thursday, June 14, 2018 9:09 AM To: Django Users Subject: How to include a Where clause for each query on django? Hello.. Each model

How to include a Where clause for each query on django?

2018-06-14 Thread Fellipe Henrique
Hello.. Each model of my app, has a field named user... so, I need to filter any query on that model user=current_user... I already do that, but manually for each model, on a view.. and I like to do that directly on some where when I try to use a query, any record will be filtered. Can I

Re: Query Regarding Django Signals

2018-05-05 Thread Ruhia gr
hello everyone m new to django and am starting my ecommerce project in djnago .please anyone suggest which is best for ecommerce project(online shopping)django or django cms On Sat, May 5, 2018 at 11:55 AM, Nipun Arora wrote: > okay thanks people..! > > On Friday, May

Re: Query Regarding Django Signals

2018-05-05 Thread Nipun Arora
okay thanks people..! On Friday, May 4, 2018 at 9:40:12 PM UTC+5:30, Nipun Arora wrote: > > Hello Community > > I was puzzled by the fact that if django signals are not asynchronous why > do we use them as in when ever i want some trigger on post_save can't i > simply write that particular

Re: Query Regarding Django Signals

2018-05-04 Thread jacob duyon
You can also just write a Celery task to do your async stuff and trigger it from signals.py On Fri, May 4, 2018 at 4:13 PM, Jani Tiainen wrote: > Hi, > > Signals are also good for decoupling things. > > For example you want to do some post save action for third party models.

Re: Query Regarding Django Signals

2018-05-04 Thread Jani Tiainen
Hi, Signals are also good for decoupling things. For example you want to do some post save action for third party models. 4.5.2018 19.10 "Nipun Arora" kirjoitti: Hello Community I was puzzled by the fact that if django signals are not asynchronous why do we use them

RE: Query Regarding Django Signals

2018-05-04 Thread Matthew Pava
] On Behalf Of Nipun Arora Sent: Friday, May 4, 2018 10:37 AM To: Django users Subject: Query Regarding Django Signals Hello Community I was puzzled by the fact that if django signals are not asynchronous why do we use them as in when ever i want some trigger on post_save can't i simply write

Query Regarding Django Signals

2018-05-04 Thread Nipun Arora
Hello Community I was puzzled by the fact that if django signals are not asynchronous why do we use them as in when ever i want some trigger on post_save can't i simply write that particular trigger in the same function that handles the request for saving a new object in django views..? as

Re: Django--Making query use part of the matching name

2018-04-28 Thread 'Anthony Flury' via Django users
What are the rules - you say that a query string of '10FTK' should match '10FTH86RSK', but also '10FTK', '10F6TK', '10FTK4' I think the problem is that the rules aren't 100% clear. * For '10FTK' to match '10FTH' you actually only care about the first 4 characters ? * For '10FTK

Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
But how about my query string? I am using 'q' as the search term 在 2018年4月26日星期四 UTC下午3:19:15,James Farris写道: > > Try using filter(id__regex=r'\w’) > > I’m not sure if this will give you the exact results your looking for, but > worth a shot. > > > Sent from my mobile de

Re: Django--Making query use part of the matching name

2018-04-26 Thread James Farris
;> GeneResul = Genes.objects.all() >>> MetaResul = Metabolites.objects.all() >>> context = dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = >>> GeneResul) >>> return render(request, "Recon/search.html", context) &

Re: Django--Making query use part of the matching name

2018-04-26 Thread shawnmhy
aResul, q=q, result_2=ReactResul, result_3 = > GeneResul) > return render(request, "Recon/search.html", context) > > > And now I want to make it more powerful. > > If I want to search '10FTH86RSK' but I cannot remember the whole name, I > can just use part o

Re: Django--Making query use part of the matching name

2018-04-25 Thread James Farris
MetaResul = Metabolites.objects.all() > context = dict(result_1=MetaResul, q=q, result_2=ReactResul, result_3 = > GeneResul) > return render(request, "Recon/search.html", context) > > And now I want to make it more powerful. > > If I want to search

Django--Making query use part of the matching name

2018-04-25 Thread shawnmhy
Resul, q=q, result_2=ReactResul, result_3 = GeneResul) return render(request, "Recon/search.html", context) And now I want to make it more powerful. If I want to search '10FTH86RSK' but I cannot remember the whole name, I can just use part of the string to make query. For exampl

Re: export sql query to excel

2018-04-16 Thread sum abiut
> > > > This is my routine to generate excel file: > from mssqlconnection import connection > import sys > import openpyxl > import os > import calendar > import time > import datetime > import smtplib > import base64 > > cursor = connection().get_connectio

Re: export sql query to excel

2018-04-16 Thread Gerardo Palazuelos Guerrero
nks Larry, > How to i pass my query parameter to the xlsxwriter. > > Cheers > > > > On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com> > wrote: > >> I use xlsxwriter and I do it like this: >> >> output = io.Byte

Re: export sql query to excel

2018-04-16 Thread Larry Martell
The same way you pass parameters to any view. On Mon, Apr 16, 2018 at 8:50 PM, sum abiut <suab...@gmail.com> wrote: > Thanks Larry, > How to i pass my query parameter to the xlsxwriter. > > Cheers > > > > On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.ma

Re: export sql query to excel

2018-04-16 Thread Larry Martell
le. The excel file was actually exported to my django >> > project folder instead. >> > >> > How to i allow the end user to be able to download the file to their >> > desktop >> > instead of exporting it to the server itself >> > >> &

Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks Larry, How to i pass my query parameter to the xlsxwriter. Cheers On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell <larry.mart...@gmail.com> wrote: > I use xlsxwriter and I do it like this: > > output = io.BytesIO() > workbook = xlsxwriter.Workbook(o

Re: export sql query to excel

2018-04-16 Thread sum abiut
esktop > > instead of exporting it to the server itself > > > > > > > > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote: > >> > >> I wrote a function to export sql query to an excel file, but some how >

Re: export sql query to excel

2018-04-16 Thread Larry Martell
16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote: >> >> I wrote a function to export sql query to an excel file, but some how the >> excel file wasn't created when the function was call. appreciate any >> assistances >> >> here is my view.py >> >

Re: export sql query to excel

2018-04-16 Thread sum abiut
the file to their desktop instead of exporting it to the server itself On Mon, Apr 16, 2018 at 3:27 PM, sum abiut <suab...@gmail.com> wrote: > I wrote a function to export sql query to an excel file, but some how the > excel file wasn't created when the function was call. ap

export sql query to excel

2018-04-15 Thread sum abiut
I wrote a function to export sql query to an excel file, but some how the excel file wasn't created when the function was call. appreciate any assistances here is my view.py def download_excel(request): if "selectdate" in request.POST: if "selectaccount&q

Django docs Polls App, Diferent queryset returns same object values but QuestionIndexViewTests works for one query and fails for other

2018-04-13 Thread Himanshu Gamit
In polls application I added annotation to check one to many relationship between Question and Choice models such that, Index only return questions with more than one choices to be displayed but my testcase fails all the time with annotation where both query returns same data. views.py

Re: How to formulate a query over two models?

2018-04-11 Thread Simon Charette
ength=200, unique=True) > > def __str__(self): > return self.value > > I want to construct a query set such that I get a dictionary back that > looks like this: > > {name1: [value1, value2,..], name2:[value3, value4,..]..} > > In other words, a dictionary th

Re: How to formulate a query over two models?

2018-04-11 Thread Christophe Pettus
> On Apr 11, 2018, at 16:19, Mark Phillips <m...@phillipsmarketing.biz> wrote: > > Thanks for the link - I have read it before. I need to stay with these > models, so is there a simple query to get my result, or do I have to make > multiple queries and combine the da

Re: How to formulate a query over two models?

2018-04-11 Thread Mark Phillips
Thanks for the link - I have read it before. I need to stay with these models, so is there a simple query to get my result, or do I have to make multiple queries and combine the data in python? Thanks, Mark On Wed, Apr 11, 2018 at 4:14 PM, Christophe Pettus <x...@thebuild.com>

Re: How to formulate a query over two models?

2018-04-11 Thread Christophe Pettus
> On Apr 11, 2018, at 16:05, Mark Phillips wrote: > > I have two models: > > # MetaData > # MetaData Value First, you might want to make sure this is *really* the best way of representing your data: http://karwin.blogspot.com/2009/05/eav-fail.html That

How to formulate a query over two models?

2018-04-11 Thread Mark Phillips
# MetaData Value class MetaDataValue(models.Model): metadata_id = models.ForeignKey(MetaData, on_delete=models.CASCADE,) value = models.CharField('value', max_length=200, unique=True) def __str__(self): return self.value I want to construct a query set such that I get a dictionary back

Re: Getting complex query set with a many to many relationship in django

2018-02-23 Thread Andy
If you want to have Articles then get Article.objects.filter(section=xy).oder_by('section__order') Am Donnerstag, 22. Februar 2018 20:47:31 UTC+1 schrieb James Farris: > > I am trying to *get all article objects that are part of a section* in an > edition that is in an issue. I am stumped, even

Getting complex query set with a many to many relationship in django

2018-02-22 Thread James Farris
I am trying to *get all article objects that are part of a section* in an edition that is in an issue. I am stumped, even after looking at the documentation for django 2.x I can get all

how to use two are more model query in a single function

2018-02-19 Thread arvind yadav
class MyObjectAdmin(admin.ModelAdmin): # A template for a very customized change view: change_form_template = 'admin/my_change_form.html' def get_dynamic_info(self): # ... pass def change_view(self, request, object_id, form_url='', extra_context=None): extra_context = extra_context

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-06 Thread Web Architect
operative > in the class Meta for that model. I’m not completely sure, but I think this > may speed up you query time. > > Thanks, > > Furbee > > On Saturday, February 3, 2018, Vijay Khemlani <vkhe...@gmail.com > > wrote: > >> Well, you should've s

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-03 Thread Furbee
You can set up an index on multiple field, as well, so if you’re searching for As without a reference from B or C, using the index_together operative in the class Meta for that model. I’m not completely sure, but I think this may speed up you query time. Thanks, Furbee On Saturday, February 3

Re: Issues with POST query in Django

2018-02-03 Thread Jani Tiainen
Hi. Unfortunately you did't provided any code and actual error (complete traceback) so if you please provide them it would be even possible to help you. 3.2.2018 16.31 kirjoitti: > Hi, > I am facing a problem in django . I have a custom authentication function >

Issues with POST query in Django

2018-02-03 Thread mohit . dubey
Hi, I am facing a problem in django . I have a custom authentication function which i am using with CBV to authenticate. In a specific CBV I have not used the authenticate function still it is going into authenticate function and raising an error. Any help is welcomed. -- You received this

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-03 Thread Vijay Khemlani
Architect <pinak...@gmail.com> wrote: > Hi Furbee, > > Thanks for your response. > > With my experience I have always noticed that a query within query kills > the mysql and Mysqld CPU usage hits the ceiling. I would still check your > alternate. > > I have mentione

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Furbee, Thanks for your response. With my experience I have always noticed that a query within query kills the mysql and Mysqld CPU usage hits the ceiling. I would still check your alternate. I have mentioned the size of A and B in response to Vijay's reply. On Saturday, February 3

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Vijay, Thanks for your response. In my scenario, there is also another model with manytomany relation with A: class C(models.Model): a = manytomany('A', related_name='cs', through='D') so, for around 25K records in A, 45K records in D and 18K records in B, following query takes more

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Furbee
There are a couple options you could try to see which is the best fit for your data. With DEBUG=True in settings.py you can check the actual queries and process time. It depends on the sizes of A and B. Another query you can run is: A.objects.exclude(id__in=B.objects.all().values_list('a_id

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Vijay Khemlani
"with large of records in A and B, the above takes lot of time" How long? At first glance it doesn't look like a complex query or something particularly inefficient for a DB. On Fri, Feb 2, 2018 at 11:31 AM, Andy <kakulu...@gmail.com> wrote: > not that i know of > >

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
not that i know of Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect: > > Hi Andy, > > Thanks for your response. I was pondering on option a before posting this > query thinking there could be better ways in django/SQL to handle this. But > now I

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Andy, Thanks for your response. I was pondering on option a before posting this query thinking there could be better ways in django/SQL to handle this. But now I would probably go with a. Thanks. On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote: > > a) Maybe its an

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
a) Maybe its an option to put the foreign key to the other model? This way you dont need to make a join to find out if there is a relation. b) Save the existing ralation status to model A c) cache the A.objects.filter(bs__isnull=False) query But apart from that i fear you cannot do much more

Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi, I am trying to optimise Django queries on my ecommerce website. One of the fundamental query is where I have no clue how to make efficient. It could be trivial and probably been known long time back. But I am new to Django and would appreciate any help. This is primarily for one to many

Can I test for count of a many to many field, in a Q query, along with other filters?

2018-01-16 Thread Mark London
If I'm creating a query using Q, can I make one of Q tests, be a count of a manytomany field?I.e., one of the Q filters, should test to see if a specific manytomany field, has a count greater than 5, I know that I can use annotate to test for count. But can annotate be specified within

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-08 Thread Tom Tanner
were asking for. :D >>>>> >>>>> Django has bunch of spatial queries, so you're looking some of those >>>>> __inside, __within lookups. Coordinate transformations do happen >>>>> automatically so you just need to provide srid for you &quo

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Jani Tiainen
t;> Django has bunch of spatial queries, so you're looking some of those >>>> __inside, __within lookups. Coordinate transformations do happen >>>> automatically so you just need to provide srid for you "envelope". >>>> >>>> On Sun, Jan 7, 2

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Tom Tanner
as bunch of spatial queries, so you're looking some of those >>> __inside, __within lookups. Coordinate transformations do happen >>> automatically so you just need to provide srid for you "envelope". >>> >>> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner <donts

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Tom Tanner
h of spatial queries, so you're looking some of those >> __inside, __within lookups. Coordinate transformations do happen >> automatically so you just need to provide srid for you "envelope". >> >> On Sun, Jan 7, 2018 at 1:48 AM, Tom Tanner <dontsende...

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Jani Tiainen
endemailher...@gmail.com> > wrote: > >> Here's a sample PostGIS query I use to get geometries within four points: >> >> SELECT * >> FROM myTable >> WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, - >> 97.65901855468752, 30.295958

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Jani Tiainen
Tom Tanner <dontsendemailher...@gmail.com> wrote: > Here's a sample PostGIS query I use to get geometries within four points: > > SELECT * > FROM myTable > WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, - > 97.65901855468752, 30.29595835209862,

Re: How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-07 Thread Jani Tiainen
her...@gmail.com> wrote: > Here's a sample PostGIS query I use to get geometries within four points: > > SELECT * > FROM myTable > WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, - > 97.65901855468752, 30.29595835209862, 4326) && S

How do I use Django to execute PostGIS query to get polygons within four points?

2018-01-06 Thread Tom Tanner
Here's a sample PostGIS query I use to get geometries within four points: SELECT * FROM myTable WHERE ST_MakeEnvelope(-97.82381347656252, 30.250444940663296, - 97.65901855468752, 30.29595835209862, 4326) && ST_Transform(myTable.geom, 4326); With this query, I can get all row

Re: Strange query when using annotate and count

2017-12-06 Thread Cristiano Coelho
Update. Found a work around that gets rid of the unnecessary group by (and hence speeds up the query, from ~200ms to ~100ms in my use case). Simply adding a .values('pk'). Bad thing, every model needs a custom manager and it will still use an inner query, still trying to figure out the side

Re: Strange query when using annotate and count

2017-12-06 Thread Cristiano Coelho
After testing for a while, there really doesn't seem to be a good way to do this. . Annotation is required since the query is filtered based on the annotated value, so any attempt to clear annotations would fail. Although a lookup could be used for the filtering. But a custom lookup

Re: Strange query when using annotate and count

2017-11-24 Thread Cristiano Coelho
was hoping I missed some flag or implementation detail on the custom function to tell the query builder to avoid all the grouping and subquery stuff, will research more... El viernes, 24 de noviembre de 2017, 14:39:27 (UTC-3), Simon Charette escribió: > > Hello Cristiano, > > If you are

Re: Strange query when using annotate and count

2017-11-24 Thread Simon Charette
cause issues if the > annotation is actually legit (ie with an aggregate) and it needs the > subquery after all. > The other option is to subclass the paginator class with a special one > that does this annotation clearing before running count. > > Even with these cases, if the a

Re: Strange query when using annotate and count

2017-11-24 Thread Cristiano Coelho
. The other option is to subclass the paginator class with a special one that does this annotation clearing before running count. Even with these cases, if the annotated value is used later with a filter query I can't really simply removed, but the sub queries and extra function calls really

Re: Strange query when using annotate and count

2017-11-23 Thread Simon Charette
rysets are smart enough to not include the order > by clause if there's a count. > > You could also suggest using two separate calls or a flag to pass down to > the internal code so it doesn't include the additional stuff, but that > wouldn't work since paginators accept only on

Re: Strange query when using annotate and count

2017-11-23 Thread Cristiano Coelho
down to the internal code so it doesn't include the additional stuff, but that wouldn't work since paginators accept only one query set for example and internall uses it for both count and results. El viernes, 24 de noviembre de 2017, 0:05:29 (UTC-3), Simon Charette escribió: > >

Re: Strange query when using annotate and count

2017-11-23 Thread Simon Charette
field" while in your other case you use a lookup (summary__icontains) which are only going to be added to the WHERE clause of your query. I'm not sure why you are annotating your queryset without referring to it in a filter clause later on but the ORM cannot simply ignore it when you are perfo

Re: Strange query when using annotate and count

2017-11-21 Thread Cristiano Coelho
Hmm, should I try with the dev mailing list? Guess it's something no one faced before? El martes, 14 de noviembre de 2017, 22:54:23 (UTC-3), Cristiano Coelho escribió: > > I'm getting some very odd query when combining annotate with count. See > the following:

Re: How to do query inner join in django rest framework

2017-11-17 Thread Jason
I would look at the django beginner tutorial first https://docs.djangoproject.com/en/1.11/intro/tutorial01/ what you're asking for is covered in part 2 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: how to do query inner join in django 1.11

2017-11-17 Thread Angel Omar Rojas Pacheco
viembre de 2017, 13:58:32 (UTC-3), Angel Omar Rojas > Pacheco escribió: >> >> hello peolpe >> >> I need your help please, I read documentation django rest >> framework/serialize, but isn't find my solution, I need this query in >> django: >> >> se

How to do query inner join in django rest framework

2017-11-16 Thread Angel Omar Rojas Pacheco
hello everyone, I am a new in django, need to inner join in django, it searching in documentation DJANGO REST FRAMEWORK / SERIALIZER, but is not looking for I am, My query in sql is: select * from auth_user as auser inner join profile_user_colony as profileu on auser.id=profileu.user_id

how to do query inner join in django 1.11

2017-11-16 Thread Angel Omar Rojas Pacheco
hello peolpe I need your help please, I read documentation django rest framework/serialize, but isn't find my solution, I need this query in django: select * from auth_user as auser inner join profilecolonybit_profile as profileu on auser.id=profileu.user_id this show me all users

Strange query when using annotate and count

2017-11-14 Thread Cristiano Coelho
I'm getting some very odd query when combining annotate with count. See the following: >>> q = > Vulnerability.objects.annotate(score=WordTrigramCustomSimilarity('test','summary')) > >>> q.count() > 3094 > >>> print connection.queries[-1] &g

Re: Django REST framework nested query.

2017-11-06 Thread Xavier Ordoquy
Hi, You are looking for nested serializers. Documentation explains how to deal with them at: http://www.django-rest-framework.org/api-guide/relations/#nested-relationships Regards, Xavier, Linovia. > Le 7 nov.

Django REST framework nested query.

2017-11-06 Thread Shamim Hossain
I am switched to Djangorest framework from Nodejs. I don't know how can I start to solve following problem. I have two django model named Category and Product. In Category model has "is_featured" boolean field. I need category list in JSON format where is_featured=true and the list of

Null characters in SQL query after having migrated to python 3.5.3

2017-10-26 Thread Etienne Robillard
b/backends/util.py" in execute 40. return self.cursor.execute(sql, params) File "/home/erob/src/django-livestore/contrib/django-1.4/django/db/backends/sqlite3/base.py" in execute 344. return Database.Cursor.execute(self, query, params) Exception Type:

Why does Case/When ungroup the results of my values() annotate() query?

2017-09-13 Thread Eric Palmitesta
Hey all! I've posted my question to StackOverflow and asked in #django on freenode but haven't gotten any responses, so I guess this mailing list is my next stop. https://stackoverflow.com/questions/45802068/why-does-case-when-ungroup-the-results-of-my-values-annotate-query It appears when I

Re: Am a new Django User and am finding difficulties making a query to my database

2017-09-13 Thread Melvyn Sopacua
Well, the simplest answer is you used the python shell and not the django shell via `python manage.py shell`. The app not being in installed apps gives a slightly different error and migrations have little to do with it as importing a model doesn't hit the database. So simply use `python

Re: Am a new Django User and am finding difficulties making a query to my database

2017-09-13 Thread Oladipupo Elegbede
Did you include your app in the installed apps list in your settings.py file? Did you do the makemigration and migration after creating the model? Check these two steps and then try again. That's what I'm suspecting given the error trace. On Sep 13, 2017 7:13 AM, "Abdul-Waris Dawuda"

Am a new Django User and am finding difficulties making a query to my database

2017-09-13 Thread Abdul-Waris Dawuda
Hello Everyone Am new to Django and am currently facing a problem trying to import a class from my models. i get this error when i try to do that from the Shell. I am using Visual Studio. i get this problem when i run my command to import; >>> from app.models import Artist Traceback (most

I AM NOT ABLE TO IMPORT CLASSES FROM MY MODELS WHEN AM TRYING TO RUN A QUERY

2017-09-13 Thread Abdul-Waris Dawuda
When i run this command in the django shell when am trying to make query to my databse i get this problem. Kindly help me out: >>>from app.models import Artist Traceback (most recent call last): File "", line 1, in File ".\app\models.py", line 8, in class

RE: Annotating a query with comparison result e.g. F('foo') == F('bar')

2017-09-01 Thread Matthew Pava
-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Daniel Hepper Sent: Friday, September 1, 2017 2:32 AM To: Django users Subject: Annotating a query with comparison result e.g. F('foo') == F('bar') I'm looking for a way to build a query that resembles this: select id

Annotating a query with comparison result e.g. F('foo') == F('bar')

2017-09-01 Thread Daniel Hepper
I'm looking for a way to build a query that resembles this: select id, user_id, user_id=7 as mine from app_status order by mine desc; (This question originally comes from a thread on Reddit). My first instinct was that it should be possible with an F expression

Re: How rewrite query in Django ORM?

2017-08-25 Thread Daniel Hepper
')).filter(field_replaced=Func(Value('my_value'), Value('-'), Value(' '), function='replace')) This results in a query like this: SELECT "T"."id", "T"."field", replace("T"."field", '-', ' ') AS "field_replaced" FROM "T&quo

Re: How rewrite query in Django ORM?

2017-08-24 Thread wang sheng
why you need rewrite query in ORM you can use "raw query" in django https://docs.djangoproject.com/en/1.11/topics/db/sql/ 2017-08-25 4:25 GMT+08:00 Николай Инкогнито <mmms...@gmail.com>: > SELECT * FROM T WHERE REPLACE(T.field, '-', ' ') = REPLACE(VALUE,'-', ' ') &g

How rewrite query in Django ORM?

2017-08-24 Thread Николай Инкогнито
SELECT * FROM T WHERE REPLACE(T.field, '-', ' ') = REPLACE(VALUE,'-', ' ') -- 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

Re: Query for retrieving the latest of a related row.

2017-08-17 Thread Jani Tiainen
Hi. Actually your way is pretty much only way to do it. With aggregation you can get latest post timestamp per forum but to get actual post requires second query. Also unless you list hundreds of forums per page performance shouldn't be a problem. Note that you could use reverse relation

Query for retrieving the latest of a related row.

2017-08-17 Thread mli...@x76.eu
).order_by('-posted').first() # the 'posts' variable is pushed into the view context for display Obviously this isn't optimal.. It would be more efficient if the above could be made into a single query, but I can't figure out how. I found some solutions through Google, but so far it is aggregations us

'Lost connection to MySQL server during query'

2017-08-03 Thread devvydev
Hi, We are using amazon AWS to run our commands that then talk to a db on amazon RDS. Our nightly commands sometimes fail with 'Lost connection to MySQL server during query' - this only happens on our big databases. If the commands are successful they usually report 28,29 mins. So we feel

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

Query about integration multiple database using mongodb

2017-07-12 Thread Shivam Taneja
Dear all I have a query using integration of multiple database support using mongoDB am strucking while implementing the multiple databases mongodb with django if you have any idea about it please provide me a link about it Regards Shivam -- You received this message because you

Query abouhe multiple database support using mongoDB

2017-07-12 Thread Shivam Taneja
Dear all I have a requirement to integrate the multiple database using mongodb is this possible to integrate the multiple database with mongodb and if possible then whats the process involved in this process Regards Shvam Taneja -- You received this message because you are subscribed to the

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-14 Thread Miika Huusko
m/questions/44461638/django-django-rest-framework-postgresql-queries-and-serialization-is-very-sl Thanks for help. On Sunday, June 11, 2017 at 5:57:22 PM UTC+3, Miika Huusko wrote: > > I have a performance problem with Django + Django REST Framework. The > problem is that it ta

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Melvyn Sopacua
your reverse related) - for each one that you don't have yet, fetch it: /files/id The hashing came into play, because corporate idiots - I mean people - attach their logo to each and every email they send. So by hashing them, you eliminate duplicates and scale down your storage requirements

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Alceu Rodrigues de Freitas Junior
I'm guessing here that REST would not be the appropriate to handle "large" amounts of data, and probably that's why Melevyn suggested to use pagination. If your customer needs such data to be used off-line, I bet that would be better to generate a file in the appropriate format, compact it

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Miika Huusko
a Huusko wrote: > > I have a performance problem with Django + Django REST Framework. The > problem is that it takes Django very, very long time to handle SQL query > response + DRF serialization take quite some time also. It happens when > there are ManyToMany or OneToMany relations a

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Melvyn Sopacua
On Sunday 11 June 2017 13:41:55 Miika Huusko wrote: > @Melvyn Sopacue, I opt to use prefetch_related because I'm fetching > "Items" that are used as ForeignKey for "Photos" and "Events". > Select_related is meant for cases where you have OneToOne of > ForeignKey relation (single item) that you

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Miika Huusko
extra looping or cloning going on when performing Python level JOIN for prefetched Photos or other related sets. On Sunday, June 11, 2017 at 4:57:22 PM UTC+2, Miika Huusko wrote: > > I have a performance problem with Django + Django REST Framework. The > problem is that it takes Django

Re: Django + Django REST Framework SQL query response handling and serialization is very, very slow - yet not a “N+1” problem

2017-06-11 Thread Melvyn Sopacua
On Sunday 11 June 2017 09:15:09 Miika Huusko wrote: > Thanks for response! > > Yep, timing with "time" is not the best way to go to compare SQL query > times. The reason I added that "time" test is that in Stack Overflow > I was asked to confirm that data t

<    1   2   3   4   5   6   7   8   9   10   >