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
name made lowercase. > > class Meta: > managed = True > db_table = 'ConferenceCall2' > > > I called makemigrations and then migrate and everything looks fine. > > However, when I run a query like Calls.objects.all() the result is: []. > > Or when I tried Calls..objects.c

Re: Django query returns nothing for legacy databse

2016-06-09 Thread Gagaro
='LeaveTime', blank=True, null= > True) # Field name made lowercase. > > class Meta: > managed = True > db_table = 'ConferenceCall2' > > > I called makemigrations and then migrate and everything looks fine. > > However, when I run a query like Calls.objects.all() the re

Django query returns nothing for legacy databse

2016-06-09 Thread Galil
db_table = 'ConferenceCall2' I called makemigrations and then migrate and everything looks fine. However, when I run a query like Calls.objects.all() the result is: []. Or when I tried Calls..objects.count() the result was: 0. The MySQL database is not empty, but apparently Django ORM

Re: Query and order by time difference of a specified time.

2016-05-23 Thread Fabio C. Barrionuevo da Luz
it would probably be better to use a custom "Func"[1] and a custom "Query Expression" [2] than user QuerySet.extra [1] https://docs.djangoproject.com/en/1.9/ref/models/database-functions [2] https://docs.djangoproject.com/en/1.9/ref/models/expressions/ On Mon, May 23, 201

Query and order by time difference of a specified time.

2016-05-23 Thread Ketan Bhatt
Take a look at the `extra` method of the queryset in Django. It allows you to do what you are trying to do by raw SQL. https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.extra Check the above link, the example with `annotate` will be interesting for

Query and order by time difference of a specified time.

2016-05-23 Thread ap.d...@x76.eu
FROM myapp_posts f ORDER BY timdif LIMIT 10; The above snippet converts the specified date and field to epoch seconds, subtracts them and then sorts the query according to the difference. Is it possible do this in Django without resorting to raw queries? Thank you. -- You received this message

[Sharing] a django app to apply filters on drf querysets using query params with validations using voluptuous.

2016-04-10 Thread Manjit Kumar
https://github.com/manjitkumar/drf-url-filters *drf-url-filters* is a simple django app to apply filters on drf modelviewset's queryset in a clean, simple and configurable way. It also supports validations on incoming query params and their values. A beautiful python package voluptouos

query on django orm :- please help me to make a django base queryset, i have tried a lot but unable to make it.

2016-04-07 Thread JAI PRAKASH SINGH
hello all, please help me to make a django base queryset, i have tried a lot but unable to make it my records present are like under Model name:- MobileInfo id brandmodel_nameprice 1aaa 123 30 2aaa 123 35 3bbb

Re: run python function in output of annotated query

2016-03-31 Thread Fabio C. Barrionuevo da Luz
[2] > https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.Field.from_db_value > > > Le jeudi 31 mars 2016 10:15:38 UTC-4, Fabio Caritas Barrionuevo da Luz a > écrit : >> >> Hello django-users, >> >> I have a unmanaged model, of legacy database

Re: run python function in output of annotated query

2016-03-31 Thread Simon Charette
: > > Hello django-users, > > I have a unmanaged model, of legacy database, used only to read. > > I need to clean the value of a field returned in a annotated query. > > I try created a new model field inherits from TextField and override > to_python method to clean the value (r

run python function in output of annotated query

2016-03-31 Thread Fabio C. Barrionuevo da Luz
Hello django-users, I have a unmanaged model, of legacy database, used only to read. I need to clean the value of a field returned in a annotated query. I try created a new model field inherits from TextField and override to_python method to clean the value (remove all html using python-bleach

Re: Can't Get ListView to display result of SQL Query onto Custom Template

2016-02-25 Thread Malik Rumi
ork. I've tried a wide variety >> of tweaks to context, but none of them worked. I tested my queryset in the >> shell, and it worked fine. Debug toolbar says my query executed. So it just >> seems to be getting it onto my template. >> >> >> This sho

Re: Can't Get ListView to display result of SQL Query onto Custom Template

2016-02-25 Thread Vijay Khemlani
ork. I've tried a wide variety > of tweaks to context, but none of them worked. I tested my queryset in the > shell, and it worked fine. Debug toolbar says my query executed. So it just > seems to be getting it onto my template. > > > This shows a list of all my Code objects > > class

Can't Get ListView to display result of SQL Query onto Custom Template

2016-02-25 Thread Malik Rumi
isn't there. I tried switching template names, but that didn't work. I've tried a wide variety of tweaks to context, but none of them worked. I tested my queryset in the shell, and it worked fine. Debug toolbar says my query executed. So it just seems to be getting it onto my template

Re: django css: general query on CDNs and crispy forms

2016-02-24 Thread Adailton (Dhelbegor)
you have a problem here: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myproject.myapp', ###Missed the point ( , ) 'crispy_forms', ###Registered ) -- You

Re: django css: general query on CDNs and crispy forms

2016-02-23 Thread Mario Gudelj
You're missing a comma after my app inside installed_apps. You can load bootstrap from cdn inside head, before your custom style sheet. Not a problem there. Pip install crispy forms. They'll end up in your site-packages folder. No need to download it and put it inside your project. Run

Re: django css: general query on CDNs and crispy forms

2016-02-23 Thread Lee Hinde
On Feb 23, 2016, at 5:27 PM, clarksonchri...@gmail.com wrote: > > Should i download bootstrap properly or do the CDNs suffice? Your call; but if you want to have a plan B, here’s an example: http://www.hanselman.com/blog/CDNsFailButYourScriptsDontHaveToFallbackFromCDNToLocalJQuery.aspx

django css: general query on CDNs and crispy forms

2016-02-23 Thread clarksonchris81
I have set up a page and have implemented bootstrap using the CDN code that is recommended to access the online bootstrap server: for the CSS: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css;

Re: Possible Bug when using exclude on a GenericForeignKey / GenericRelation query.

2016-02-22 Thread Tim Graham
n error which I think might be a bug. I've yet > to try and replicate it as I thought posting here would be the better first > step, as I might just be doing something incorrectly. > > When I try a query with .exclude() on a table with a GenericForeignKey and > a reverse Generic

Re: Is there a hook to run an SQL Query at every Postgres session start?

2016-02-03 Thread Bobby Mozumder
Cheers, > Simon > > [1] https://docs.djangoproject.com/en/1.9/ref/signals/#connection-created > > Le mercredi 3 février 2016 12:25:36 UTC-5, Bobby Mozumder a écrit : > I'm looking to use PREPARE/EXECUTE statements, to eliminate my Query Planning > time from every Web request. >

Re: Is there a hook to run an SQL Query at every Postgres session start?

2016-02-03 Thread Simon Charette
to use PREPARE/EXECUTE statements, to eliminate my Query > Planning time from every Web request. > > This can be done via SQL PREPARE/EXECUTE statements. > > But, Postgres only supports PREPARE statements on a connection > session-by-session basis. > > To do this with Dj

Is there a hook to run an SQL Query at every Postgres session start?

2016-02-03 Thread Bobby Mozumder
I'm looking to use PREPARE/EXECUTE statements, to eliminate my Query Planning time from every Web request. This can be done via SQL PREPARE/EXECUTE statements. But, Postgres only supports PREPARE statements on a connection session-by-session basis. To do this with Django, I need to be able

Re: like query django

2016-01-23 Thread Xristos Xristoou
i have 1.8 version Τη Τρίτη, 19 Ιανουαρίου 2016 - 5:35:09 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > > hello, > > > i want to create a query for likes in my post details > > my html tags > > {{movies.likes}} peaple liked this article > Like >

Re: like query django

2016-01-23 Thread James Schneider
On Jan 22, 2016 1:08 AM, "Xristos Xristoou" wrote: > > look my version django cant not be use url 'like_post' because show me errow only 1.5 version django can use that > I have no idea what you are trying to say here, sorry. Are you using Django 1.5? If so, you should

Re: like query django

2016-01-22 Thread Xristos Xristoou
look my version django cant not be use url 'like_post' because show me errow only 1.5 version django can use that Τη Τρίτη, 19 Ιανουαρίου 2016 - 5:35:09 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > > hello, > > > i want to create a query for likes in my post details &

Re: like query django

2016-01-21 Thread James Schneider
On Tue, Jan 19, 2016 at 10:56 AM, Xristos Xristoou wrote: > i follow you not work again first i cant use {% url %} show me template > error,i thing so i am is very noob > must necesery tu urls for that ? > Can you post your template with the changes you made? And the errors

Re: like query django

2016-01-19 Thread Xristos Xristoou
i follow you not work again first i cant use {% url %} show me template error,i thing so i am is very noob must necesery tu urls for that ? Τη Τρίτη, 19 Ιανουαρίου 2016 - 5:35:09 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > > hello, > > > i want to create a query for likes in

Re: like query django

2016-01-19 Thread James Schneider
> > {{movies.likes}} peaple liked this article > Like > > > This is not how you should generate URL's within your templates. You should be using the {% url %} tag to automatically generate them: Like If using the slug in your urls.conf, your {% url %} tag would look something like this: Like

Re: like query django

2016-01-19 Thread Xristos Xristoou
not work again florian same error again Τη Τρίτη, 19 Ιανουαρίου 2016 - 5:35:09 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > > hello, > > > i want to create a query for likes in my post details > > my html tags > > {{movies.likes}} peaple liked this article >

Re: like query django

2016-01-19 Thread Florian Schweikert
On 19/01/16 16:35, Xristos Xristoou wrote: > url(r'^view/(?P[^\.]+)/$', views.view_post, name='view_post'), > url(r'^(?P[0−9]+)/$', views.like_post, name='like_post'), this defines urls like /1/ > The current URL, |like/1/|, didn't match any of these. of course it doesn't, you didn't define a

like query django

2016-01-19 Thread Xristos Xristoou
hello, i want to create a query for likes in my post details my html tags {{movies.likes}} peaple liked this article Like my urls url(r'^view/(?P[^\.]+)/$', views.view_post, name='view_post'), url(r'^(?P[0−9]+)/$', views.like_post, name='like_post'), my view def like_post(request,pk=1

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: 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 1.6.11 model class query

2015-11-24 Thread Nikunj Badjatya
Better late than never. Thank you ! This really helped. -- 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

Re: matching query does not exist.

2015-11-20 Thread Becka R.
because the table is populated with data, but >> until someone signs up for a shift, "camper" is set to None. The page is >> rendering and displaying data correctly, but when I go to add myself as a >> logged in user, I get the following error: >> >> Doe

Re: matching query does not exist.

2015-11-19 Thread Andrew Farrell
"camper" is set to None. The page is > rendering and displaying data correctly, but when I go to add myself as a > logged in user, I get the following error: > > DoesNotExist at /signup/ > > mealShifts matching query does not exist. > > > Code is below. Thanks fo

matching query does not exist.

2015-11-19 Thread Becka R.
a logged in user, I get the following error: DoesNotExist at /signup/ mealShifts matching query does not exist. Code is below. Thanks for any help. Signup is the name of the template and the view function. mealShifts (which I know needs to be capitalized) is the name of the model. Here'

Re: DoesNotExist: Group matching query does not exist.

2015-11-12 Thread James Schneider
> File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 334, in get > > self.model._meta.object_name > > DoesNotExist: Group matching query does not exist. > > > Can someone help me ? > BTW, this is a standard exception rai

Re: DoesNotExist: Group matching query does not exist.

2015-11-12 Thread Robin Fourcade
Thanks for your reply, It was in the DB but, I don't know why, I had this issue. I made the migration a second time and this time, it worked. Thanks, Robin. -- Solved. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this

Re: DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Vijay Khemlani
queryset(), name)(*args, **kwargs) > > File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", > line 334, in get > > self.model._meta.object_name > > DoesNotExist: Group matching query does not exist. > > > Can someone help me ? >

DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Robin Fourcade
get_queryset(), name)(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 334, in get self.model._meta.object_name DoesNotExist: Group matching query does not exist. Can someone help me ? Thanks, Robin. -- You received this mess

Re: simplify query

2015-11-10 Thread miguel angel lopez mendo
Jajaja para nada de hecho ya quedo lo deje asi para cualquiera que lo necesite: ---view-- def clientes(request): clientes = Clientes.objects.order_by('Nombre') clientes2 = Clientes.objects.order_by('Nombre').filter(medio='1') clientes3 =

Re: simplify query

2015-11-10 Thread Luke M
Yo no se verdaderamente si estas 'trolling' ... pero bueno, si no, puedo decirte exactamente lo que pasa - usas `objects.appened` en lugar de `objects.append`, a ver: https://docs.python.org/3/tutorial/datastructures.html#more-on-lists Despues el 'for' loop, tienes una lista de listas que son

Re: simplify query

2015-11-10 Thread miguel angel lopez mendo
ya lo acomode pero aun asi me manda este error Te dejo mi template para que veas tambien {% for clientes in objects %}

Re: simplify query

2015-11-10 Thread lukewm
Check your indentation, it's off starting from the line below `import string`. My email client kinda borked my indentation, so you need to take care. On 2015-11-10 17:30, miguel angel lopez mendo wrote:

Re: simplify query

2015-11-10 Thread miguel angel lopez mendo
i have the next view but it does not work

Re: simplify query

2015-11-10 Thread lukewm
Haven't run this code, but you could try something like: ``` import string myletters = string.ascii_letters[:16] objects = [] order = 'Nombre' for letter in myletters: filters = {'Nombre__startswith': letter}

simplify query

2015-11-10 Thread miguel angel lopez mendo
a = Clientes.objects.filter( Nombre__startswith='A').order_by('Nombre') b = Clientes.objects.filter( Nombre__startswith='B').order_by('Nombre') c = Clientes.objects.filter( Nombre__startswith='C').order_by('Nombre') d = Clientes.objects.filter( Nombre__startswith='D').order_by('Nombre') e =

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Gagaro
oks like the following thing is happening, > you find have a similar example in the documentation > <https://docs.djangoproject.com/en/1.8/topics/db/models/#extra-fields-on-many-to-many-relationships> > . > > When you define an explicit through model Django generate

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Gagaro
On Friday, 23 October 2015 16:35:32 UTC+2, Tom Evans wrote: > > 'Wishlist.user' and 'User.wishlist' are the names of the fields being > discussed. The meaning might be clearer with some added words: > > The reverse query name for the field 'Wishlist.user' clashes wi

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Simon Charette
Django generates a query name to allow direct reference to the intermediate relationship. This query name is not customizable and is generated by lower casing the intermediate model name ('wishlist' in your case and 'membership' in the linked one). The clash you're getting here is between this im

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread 'Tom Evans' via Django users
message doesn't mention the reverse relation names that conflict, it mentions the names of *fields* whose relation names would conflict. > Reverse query name for 'Wishlist.user' clashes with field name > 'User.wishlist'. > HINT: Rename field 'User.wishlist', or add/change a related_name argum

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Gagaro
ine') >> user = models.ForeignKey('User') >> >> >> class Wine(models.Model): >> name = models.CharField(max_length=32) >> >> >> class User(models.Model): >> name = models.CharField(max_length=32) >> wishlist = model

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Simon Charette
ield(max_length=32) > > > class User(models.Model): > name = models.CharField(max_length=32) > wishlist = models.ManyToManyField(Wine, through=Wishlist) > > And the following error: > > models_test.Wishlist.user: (fields.E303) Reverse query name for >> 'Wishlist

Reverse query name clashe with a M2M and through

2015-10-23 Thread Gagaro
= models.CharField(max_length=32) wishlist = models.ManyToManyField(Wine, through=Wishlist) And the following error: models_test.Wishlist.user: (fields.E303) Reverse query name for > 'Wishlist.user' clashes with field name 'User.wishlist'. > HINT: Rename field 'User.wishlist', or add/

Solr query through Scorched/Sunburnt

2015-10-14 Thread Pippo Pluto
I have a weird problem. I'm querying a Solr 5.3 instance with Django through Scorched. It all works great as far as I don't ask an exact-match query. In other words, q=something something else returns exactly the same result as: q="something something else" The culprit, as fa

Re: Slow query even for small number of rows

2015-10-03 Thread James Schneider
Chong" <yiksurn.ch...@gmail.com> wrote: > Hi guys, > > I wonder why my query to view the list of scholarships takes quite long to > load even though the number of rows is small. Would be great if someone > could help me out here. > > Thanks. > > Here'

Slow query even for small number of rows

2015-10-03 Thread Yik Surn Chong
Hi guys, I wonder why my query to view the list of scholarships takes quite long to load even though the number of rows is small. Would be great if someone could help me out here. Thanks. Here's my view. > class DualSerializerViewSet(viewsets.ReadOnlyModelViewSet): > qu

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

2015-09-28 Thread Gergely Polonkai
, "gintare" <g.statk...@gmail.com> wrote: > 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, ...th

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,

Re: Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-24 Thread Shawn Milochik
I couldn't find it in Django's documentation; just from StackOverflow and another source (both found via Google). I always used to do something like Thing.objects.filter(other__id__isnull=True) to do that, but clearly this is better. -- You received this message because you are subscribed to

Re: Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-24 Thread Edward Sitarski
Thanks - didn't see that one. For my own reference/sanity, can you attach a link where this is documented? I should have found this one <http://stackoverflow.com/questions/4184558/django-query-filter-on-manytomany-is-empty> before too. > -- You received this message be

Re: Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-21 Thread Shawn Milochik
No articles: Publication.objects.filter(article_set=None) Has articles: Publication.objects.exclude(article_set=None) -- 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

Django Many-to-many Query: Publications with no Articles? Publications with some Articles?

2015-08-21 Thread Edward Sitarski
for publication in Publication.objects.all() if publication.article_set.all().exists()] But, that's slow if you have a lot of publications - a query for each one. Is there a way to formulate the queries with no loop, returning a QuerySet? Apologies in advance if I am missing something simple... -- You recei

WHEN EXISTS Query in SQL to Django Queryset

2015-08-20 Thread Dheerendra Rathor
Hello, I've a complex SQL Query SELECT DISTINCT "event_event"."id", "event_event"."title", "event_event". "description", "event_event"."category", "event_event"."event_time", "event_event&q

Re: Django 1.6.11 model class query

2015-08-19 Thread 'Tom Evans' via Django users
ur DB level trigger modifying the data that it serializes. You have two straightforward options - move the uuid setting code to a django pre-save hook (ideally using the built in UUID field), or every time you save an object, remember to re-fetch it from the database. Whatever you do, presumably you ar

Re: Django 1.6.11 model class query

2015-08-19 Thread Vijay Khemlani
I'm guessing Django does not update all of the fields of the instance when saving it, only the id On Wed, Aug 19, 2015 at 11:31 AM, Nikunj Badjatya wrote: > Also, > When the same object is retrieved using > > > print(Test.objects.get(id=row.id).uuid) # Prints uuid. >

Re: Django 1.6.11 model class query

2015-08-19 Thread Nikunj Badjatya
Also, When the same object is retrieved using print(Test.objects.get(id=row.id).uuid) # Prints uuid. -- 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 1.6.11 model class query

2015-08-19 Thread Nikunj Badjatya
Hello All, I have a django model class defined as: class Test(models.Model): id=AutoField(primary_key=True) name = models.CharField(max_length=45, null=False) description = models.CharField(max_length=200, null=True) uuid = models.CharField(max_length=250) class Meta:

Re: Query question

2015-08-17 Thread Dheerendra Rathor
You should use 'F' expression from django.db.models So your expression would be like: ProductSale.objects.all().filter(date_expires__lt = now().date).exclude( date_purchased__gt = F('date_expires')) Which roughly translates to SELECT * FROM productsale WHERE date_expires < CURRENT_DATE AND NOT

Re: Query question

2015-08-17 Thread Dheerendra Rathor
You should use 'F' expression from django.db.models So your expression would be like: ProductSale.objects.all().filter(date_expires__lg = now()).exclude(date_purchased__gt = F('date_expires')) On Tuesday, 18 August 2015 06:26:56 UTC+5:30, Lee Hinde wrote: > > Given this model, I want to find

Query question

2015-08-17 Thread Lee Hinde
Given this model, I want to find all ProductSale objects that have expired and where the Person doesn't have a later (unexpired) purchase of the same product. class ProductSale(models.Model): product = models.ForeignKey(Product) person = models.ForeignKey(Person) ... date_expires =

Possible Bug when using exclude on a GenericForeignKey / GenericRelation query.

2015-08-14 Thread Daniel H
incorrectly. When I try a query with .exclude() on a table with a GenericForeignKey and a reverse Generic Relation on a different table, I get this: AttributeError at /list 'GenericRelation' object has no attribute 'field' Here is a mock up of my database structure: class InternalOffer(models.Model

Re: ORM Query question

2015-07-13 Thread Joss Ingram
ou can try caching the query > > On Mon, Jul 13, 2015 at 6:08 PM, Joss Ingram <joss@gmail.com > > wrote: > >> Ok, thanks fair enough. >> >> my Question then is : >> >> Is the query above bad? >> >> On Mon, Jul 13, 2015 at 4:00 PM, Avraha

Re: ORM Query question

2015-07-13 Thread Avraham Serour
Personally I don't see obvious errors, but it is hard to tell with only this small snippet. If it works what are you worried about? Performance? If you are having performance problems you can try caching the query On Mon, Jul 13, 2015 at 6:08 PM, Joss Ingram <joss.ing...@gmail.com> wrote:

Re: ORM Query question

2015-07-13 Thread Joss Ingram
Ok, thanks fair enough. my Question then is : Is the query above bad? On Mon, Jul 13, 2015 at 4:00 PM, Avraham Serour <tovm...@gmail.com> wrote: > You told a story but didn't ask a question > > On Mon, Jul 13, 2015 at 5:54 PM, Joss Ingram <joss.ing...@gmail.com> > wro

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

HStore values query with contains not working as expected

2015-06-22 Thread Alex Magidow
Hi, I was going to file this as a bug, but it said to ask the mailing list first. When using an HStore __values query with __contains chained on to it, the query does not work as expected in Django 1.8.2. Expected action is that any values which contain the text will be returned from

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, Thanks a lot for your efforts. It worked with savepoint called before update query. Thank you Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really new to Django and I am using Django 1.8. Many of the > manual_transaction feat

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi James, Yes, it workedd :) I created the object outside the method and called it at every transaction point in the loop and when there is rollback, it rollbacks all the queries. Thanks James Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really

Re: rollback the update query

2015-05-13 Thread James Schneider
Did you try changing the position of the save point like I mentioned? -James On May 13, 2015 9:33 PM, "Simran Singh" <er.simransing...@gmail.com> wrote: > Hi James, > > Thanks for your feedback. I basically want to rollback that query where I > update the db. Basi

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi James, Thanks for your feedback. I basically want to rollback that query where I update the db. Basically I want to rollback all the updates that were made during that transaction. Tried out the method of custom Exception as suggested by Tom but somehow my bad luck that it is still

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, I tried the code that you posted but somehow it is giving* UnexpectedNoAssetSpecificationException at /reservation/ *error. I am not sure but when this exception is raised, then control is not going to class UnexpectedNoAssetSpecificationException(Exception): pass and when it

Re: rollback the update query

2015-05-13 Thread James Schneider
> asset_spec = AssetSpecification.objects.filter(asset_id_id=inventory,utilized_value=0).values_list('asset_id', flat=True) > trans = transaction.savepoint() // Here I am trying not to commit the code and store it in transaction. > > if

Re: rollback the update query

2015-05-13 Thread Simran Singh
Hi Tom, All these conditions are to be verified before data received from the form is saved in database. I tried this Exception method but when the control goes to except block, new page is rendered but *all the transactions that were completed till this point are committed after this point*.

Re: rollback the update query

2015-05-13 Thread Tom Evans
On Wed, May 13, 2015 at 9:37 AM, Simran Singh wrote: > Tom, basically I want to discard everything that is stored in > transaction.savepoint. As per my current case, it is getting committed no > matter where the flow goes. Yes, so you don't want savepoints. Savepoints

Re: rollback the update query

2015-05-13 Thread Simran Singh
Tom, basically I want to discard everything that is stored in transaction.savepoint. As per my current case, it is getting committed no matter where the flow goes. Regards, Simran On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote: > > I am really new to Django and I am using

Re: rollback the update query

2015-05-13 Thread Tom Evans
On Wed, May 13, 2015 at 6:36 AM, Simran Singh wrote: > Hi Tom, > > If you see then in if block, I am creating my savepoint. At any point of > time, if the condition is not met and control goes to else block then I want > to rollback all the changes that are saved in

Re: rollback the update query

2015-05-12 Thread Simran Singh
Hi Tom, If you see then in *if *block, I am creating my savepoint. At any point of time, if the condition is not met and control goes to *else* block then I want to rollback all the changes that are saved in transaction and redirect it to some other page and not commit anything to db. I am

Re: rollback the update query

2015-05-12 Thread Tom Evans
On Tue, May 12, 2015 at 7:47 AM, Simran Singh wrote: > Thanks Tom for your response. I am attaching piece of code of what I have > done. I hope this could help. > > @transaction.atomic(None, True) > def reservation(request): > > if request.method == 'POST': >

Re: rollback the update query

2015-05-12 Thread Simran Singh
Thanks Tom for your response. I am attaching piece of code of what I have done. I hope this could help. @transaction.atomic(None, True) def reservation(request): if request.method == 'POST': reservation_form = ReservationForm(request.POST) if

Re: rollback the update query

2015-05-11 Thread Tom Evans
On Mon, May 11, 2015 at 11:44 AM, Simran Singh wrote: > I am really new to Django and I am using Django 1.8. Many of the > manual_transaction features have been depreciated in this. I have used > @transaction.atomic(None, True) nit; these are the defaults. You might

rollback the update query

2015-05-11 Thread Simran Singh
I am really new to Django and I am using Django 1.8. Many of the manual_transaction features have been depreciated in this. I have used *@transaction.atomic(None, True)* to pack the transaction and rollback the updates if at any point the condition is not met. I tried to store the transaction

Django Custom lookup running different SQL query than it's displaying in str(query)

2015-04-16 Thread d33tah
"w_a"."title" FROM "w_a" WHERE REVERSE("w_a"."title") LIKE REVERSE(%b)`, while running the command would result in `SELECT "w_a"."id", "w_a"."title" FROM "w_a" WHERE REVERSE("w_a"."ti

<    3   4   5   6   7   8   9   10   11   12   >