Re: ORM from the command line

2020-04-09 Thread Tim Johnson
Thank you too Adam. Great stuff! On 4/9/20 7:43 AM, Adam Mičuda wrote: Hi, you can also write simple python script and run it in Django context via https://django-extensions.readthedocs.io/en/latest/runscript.html from `django-extensions` package. Best regards. Adam čt 9. 4. 2020 v 17:14

Re: ORM from the command line

2020-04-09 Thread Adam Mičuda
Hi, you can also write simple python script and run it in Django context via https://django-extensions.readthedocs.io/en/latest/runscript.html from `django-extensions` package. Best regards. Adam čt 9. 4. 2020 v 17:14 odesílatel Tim Johnson napsal: > Thank you Andréas. I have come across that t

Re: ORM from the command line

2020-04-09 Thread Tim Johnson
Thank you Andréas. I have come across that too, after my OT. This is definitely what I was looking for. cheers On 4/9/20 2:05 AM, Andréas Kühne wrote: Hi Tim, What you probably should do is use a custom command on the manage.py command interface. You till then get access to all of djangos go

Re: ORM from the command line

2020-04-09 Thread Andréas Kühne
Hi Tim, What you probably should do is use a custom command on the manage.py command interface. You till then get access to all of djangos goodness - and it can be run from the command line. See here: https://docs.djangoproject.com/en/3.0/howto/custom-management-commands/ This is how I would han

Re: orm relation

2019-12-12 Thread Dvs Khamele
Hi We are worlds first affordable Python, Django Based Commpany, And can help you in this and related tasks / projects immidiately mere at $7 per hour Best Regards, Divyesh Khamele, Pythonmate On Sun, 1 Dec 2019 at 19:39, bill dexter <55dexte...@gmail.com> wrote: > ELECT a.matr > ,[nom] >

Re: orm relation

2019-12-03 Thread Integr@te System
Hi issuer, Plz refer to docs to customize statement base on your use case, my work for a sample with limited time. Plz try remove space around equal sign. On Tue, Dec 3, 2019, 19:26 bill dexter <55dexte...@gmail.com> wrote: > hi friend; > i tryed your answer, but it says that error in syntax n

Re: orm relation

2019-12-03 Thread bill dexter
hi friend; i tryed your answer, but it says that error in syntax near __gt in "" extractyear(dat_enc) - extractyear(annee)__gt = 3""; don't work Le lun. 2 déc. 2019 à 20:31, Integr@te System a écrit : > Hi friend, > > All_list = list(users.object.aggregate(age = > cast(extractyear(datetime.now

Re: orm relation

2019-12-02 Thread Integr@te System
Hi friend, All_list = list(users.object.aggregate(age = cast(extractyear(datetime.now()) - extractyear(dat_nais), output_field = IntField())).filter(extractyear(dat_enc) - extractyear(annee)__gt = 3 & extractyear(datetime.now()) - extractyear(dat_nais)__IN=range(54,70) & cod_nad__contain = 'CN').o

Re: orm relation

2019-12-02 Thread bill dexter
thank you, but if you can give me answer to this exacte probleme, as mentioned in question Le dim. 1 déc. 2019 à 18:55, Integr@te System a écrit : > Hi, > > here u can try for complex queryset > > > > https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q > > On Sun, De

Re: orm relation

2019-12-01 Thread Integr@te System
Hi, here u can try for complex queryset https://docs.djangoproject.com/en/2.2/topics/db/queries/#complex-lookups-with-q On Sun, Dec 1, 2019, 21:08 bill dexter <55dexte...@gmail.com> wrote: > ELECT a.matr > ,[nom] > ,[prn] > ,cast([dat_nais] as date) as dat_nais > , (YEAR(ge

Re: ORM

2019-09-17 Thread Jani Tiainen
Most tools are capable of exporting uml to code format. A little googlin should help. ma 16. syysk. 2019 klo 18.57 Yann Mbella kirjoitti: > I needed the contrary having uml diagrams and generating models from > does diagram > > Le lun. 16 sept. 2019 à 16:43, Yann Mbella a > écrit : > >> Thanx f

Re: ORM

2019-09-16 Thread Yann Mbella
I needed the contrary having uml diagrams and generating models from does diagram Le lun. 16 sept. 2019 à 16:43, Yann Mbella a écrit : > Thanx for the information > > Le ven. 13 sept. 2019 à 06:24, Jani Tiainen a écrit : > >> Hi. >> >> There exists django-extensions package that has management

Re: ORM

2019-09-16 Thread Yann Mbella
Thanx for the information Le ven. 13 sept. 2019 à 06:24, Jani Tiainen a écrit : > Hi. > > There exists django-extensions package that has management command to make > UML diagram for your models. > > > pe 13. syysk. 2019 klo 5.22 Yann Mbella > kirjoitti: > >> Got little problem is it possible t

Re: ORM

2019-09-12 Thread Jani Tiainen
Hi. There exists django-extensions package that has management command to make UML diagram for your models. pe 13. syysk. 2019 klo 5.22 Yann Mbella kirjoitti: > Got little problem is it possible to have a plugin which mapps or > reproduce my class diagrams drawn in an IDE of UML in my models a

Re: Orm Query for this type of situation

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

Re: Orm Query for this type of situation

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

Re: Orm Query for this type of situation

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

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
*From:* django-users@googlegroups.com [mailto: > django-users@googlegroups.com] *On Behalf Of *b...@tanners.org > *Sent:* Monday, May 6, 2019 12:44 PM > *To:* Django users > *Subject:* Re: ORM help with INNER JOIN and GROUP BY > > > > Just want to make sure I understand. ForeighKeys need

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread bob
class Monolithic(models.Model): facepng_id = models.IntegerField(blank=True, null=True) facepng_id as Integer not ForeignKey? > UPDATE items_monolithic SET facepng_id=items_monolithic.id FROM items_monolithic INNER JOIN items_facepng ON items_monolithic.object=items_facepng.obj ; Error: near

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
Maybe that was a typo? The foreignkey relationship would look like this: object = models.ForeignKey(FacePng'', max_length=128, blank=False, null=False, unique=True) On Mon, May 6, 2019 at 12:44 PM wrote: > Just want to make sure I understand. ForeighKeys need to be integers? > > Only integers?

RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
: Re: ORM help with INNER JOIN and GROUP BY Just want to make sure I understand. ForeighKeys need to be integers? Only integers? You need a ForeignKey relationship between the two models, which is an integer value, not a char. You’d have to do migrations to get this adjusted properly. -- You

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread bob
Just want to make sure I understand. ForeighKeys need to be integers? Only integers? You need a ForeignKey relationship between the two models, which is an > integer value, not a char. You’d have to do migrations to get this adjusted > properly. > -- You received this message because you a

Re: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Kevin Jay
The field within your class should be set to ForeignKey. Try this: Object = models.ForeignKey(‘FacePng’, on_delete=SET_NULL, max_length= some_int) on_delete and max_length need to be set based on your requirements Sent from my iPhone > On May 6, 2019, at 11:28 AM, b...@tanners.org wrote: > >

RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
That design could definitely be improved, and it will have to be in order to use the ORM effectively. Then you’d have to change every reference to the fields in all the raw querysets in the app. You need a ForeignKey relationship between the two models, which is an integer value, not a char. Yo

Re: ORM - Subquery / Window

2018-06-07 Thread marco . nicotra
As suggested i'm writing what i've already tried: Raw SQL using the query written in the first message, selecting only the id field and passing it to the ORM as id__in=ids. Slow as hell, unusable. Declared a WIndow function to use as filter: Article.objects.annotate(max_rev=Window(expression=Ma

Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-12-21 Thread Peter of the Norse
This should be a bug. Most databases don’t even allow foreign keys to be a different type. I didn’t see anything in the docs about this, but it should happen automatically. There are several examples of using non-int fields, e.g. UUID. Can you provide your migration file for OmEvent and mode

Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Dominik Szmaj
Hey, 'case_id' is a monkeypatch number(*) field so it works quick for now, not a pk, but unique: class OmEvent(Model): case = ForeignKey('CaseInfo2', to_field='case_id', related_name='events', blank=True, null=True) class Meta: db_table = 'om_event' old form: class OmEve

Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Jani Tiainen
Please, post your models in question. It's probably something really simple to resolve in general. On 21.11.2017 15.59, Avraham Serour wrote: can you post your model? On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj mailto:dominik.sz...@snello.pl>> wrote: Hey, I have a very big perf

Re: [ORM Foreign Keys][Performance] How to use Charfield Foreign Keys efficiently?

2017-11-21 Thread Avraham Serour
can you post your model? On Tue, Nov 21, 2017 at 3:31 PM, Dominik Szmaj wrote: > Hey, > > I have a very big performance problem with Django and Oracle db. > > This legacy db has lots of primary keys as strings from the time when > those id's were alphanumerical so it can't be simply converted to

Re: ORM for structured Logs

2017-04-10 Thread guettli
Thank you for sharing. Yes, the model is not difficult, that's why everybody helps himself up to now. Maybe this is the best solution and there is not much in common. The things which are in common (ORM, Admin-Interface) are already provided by django. It's just a bit of glue-code to get it w

Re: ORM for structured Logs

2017-04-08 Thread Scot Hacker
On Tuesday, April 4, 2017 at 5:18:42 AM UTC-7, guettli wrote: > > In the past I was told: Don't store logs in the database. > For general purposes, I agree with this. Logging is a python standard, logs can be verbose, logrolling solutions are well established (and built in), etc. However, there

Re: ORM for structured Logs

2017-04-07 Thread guettli
Hi Marten, Am Donnerstag, 6. April 2017 14:10:58 UTC+2 schrieb knbk: > > Hi Thomas, > > The primary purpose of logging is to catch and examine errors. If > something went wrong, you want to know *when *and *why*. Logging to a > database increases the complexity and greatly increases the number o

Re: ORM for structured Logs

2017-04-07 Thread guettli
Am Donnerstag, 6. April 2017 10:42:17 UTC+2 schrieb Christian Ledermann: > > On 6 April 2017 at 09:15, guettli > > wrote: > > Hello Brick Wall, how are you doing? > > Hello Stonemason. > > What is your question? > > It was more an idea than a question. The question could be: What do you th

Re: ORM for structured Logs

2017-04-06 Thread knbk
Hi Thomas, The primary purpose of logging is to catch and examine errors. If something went wrong, you want to know *when *and *why*. Logging to a database increases the complexity and greatly increases the number of things that can go wrong. The last thing you want to find out when retracing a

Re: ORM for structured Logs

2017-04-06 Thread Christian Ledermann
On 6 April 2017 at 09:15, guettli wrote: > Hello Brick Wall, how are you doing? Hello Stonemason. What is your question? I do not have a strong opinion on your approach - i don't even know the problem you are trying to solve. or how big your logs are. a couple of KB per day or some GB per hour?

Re: ORM for structured Logs

2017-04-06 Thread guettli
Hello Brick Wall, how are you doing? Am Dienstag, 4. April 2017 14:18:42 UTC+2 schrieb guettli: > > In the past I was told: Don't store logs in the database. > > Time (and hardware) has changed. > > I think it is time to store logs where I have great tools for analyzing > logs. > > Storing in a m

Re: ORM PostgreSQL stuff

2016-11-26 Thread Avraham Serour
I didn't quite understood the question, you want to find the division of two prices for each item, but each item has only one price according to the model you posted. can you express what you want to accomplish in python or SQL? On Sat, Nov 26, 2016 at 10:15 PM, Artem Bernatskyy < artem.bernats..

Re: ORM Query question

2015-07-13 Thread Joss Ingram
Ok, thanks. On Monday, 13 July 2015 16:14:29 UTC+1, Avraham Serour wrote: > > 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 qu

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 wrote: > Ok, thanks fair enough. > >

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 wrote: > You told a story but didn't ask a question > > On Mon, Jul 13, 2015 at 5:54 PM, Joss Ingram > wrote: > >> I'm not getting much joy with my question, is there too litt

Re: ORM Query question

2015-07-13 Thread Avraham Serour
You told a story but didn't ask a question On Mon, Jul 13, 2015 at 5:54 PM, Joss Ingram wrote: > I'm not getting much joy with my question, is there too little info? > > On Friday, 10 July 2015 15:31:50 UTC+1, Joss Ingram wrote: >> >> Hi, >> >> In my models I have an event index page type, which

Re: ORM Query question

2015-07-13 Thread Joss Ingram
I'm not getting much joy with my question, is there too little info? On Friday, 10 July 2015 15:31:50 UTC+1, Joss Ingram wrote: > > Hi, > > In my models I have an event index page type, which can have child event > pages, each event page can be tagged (using taggit), and I want to produce > a

Re: ORM performance

2014-09-04 Thread Michael P. Soulier
On 04/09/14 Benjamin Scherrey said: > The short answer to your question is no, the Django ORM is not inherently > slower in that regard and it's very likely something you're doing. The Given that it's basically for obj in foo.objects.all(): obj.prop = new_value obj.save() I fail to see

Re: ORM performance

2014-09-04 Thread Michael P. Soulier
On 03/09/14 Tom Lockhart said: > I haven't had to deal with this myself, but the speed difference smacks of > transactional issues. If you can run your loop by wrapping all of it or > pieces of it (say, 100 or 1000 chunks) in a single transaction you'll > probably see some significant speedup. Ye

Re: ORM performance

2014-09-04 Thread Michael P. Soulier
On 04/09/14 Tom Evans said: > Is the update invariant? By using the ORM like this: As I said, each update is unique and they cannot be batched. > Are both Django and the sqlalchemy doing the same sort of update? Yes. Identical. Mike -- You received this message because you are subscribed to

Re: ORM performance

2014-09-04 Thread Tom Evans
On Thu, Sep 4, 2014 at 12:22 AM, msoulier wrote: > Hi, > > I am looking at Django's performance with respect to modifying large numbers > of objects, each in a unique way that cannot be batched. If I make a simple > change to one of my Django models and save(), and then do the same thing in > sqla

Re: ORM performance

2014-09-03 Thread Sithembewena Lloyd Dube
Thanks to the OP for asking this, and to all who answered. Ben, special stars to you - you just shared some very valuable insight into efficieint use of the ORM (wasn't obvious to me). Kind regards, Lloyd On Thu, Sep 4, 2014 at 2:21 AM, Benjamin Scherrey wrote: > The short answer to your quest

Re: ORM performance

2014-09-03 Thread Benjamin Scherrey
The short answer to your question is no, the Django ORM is not inherently slower in that regard and it's very likely something you're doing. The useful answer is probably more complicated. :-) Naive usage of the ORM without an understanding of how it translates to SQL is likely to result in some re

Re: ORM performance

2014-09-03 Thread Tom Lockhart
On 2014-09-03, at 4:22 PM, msoulier wrote: > Hi, > > I am looking at Django's performance with respect to modifying large numbers > of objects, each in a unique way that cannot be batched. If I make a simple > change to one of my Django models and save(), and then do the same thing in > sqla

Re: ORM Question

2014-04-03 Thread Bill Freeman
>From the lack of other folks jumping in saying "do it this way", I'm going to guess that this is a hard problem. I am not a database heavyweight. (IANADbH) I especially don't know about limitations of MySQL. It seems that you need to calculate a maximum size of Llama objects, but separately for

Re: ORM Question

2014-04-02 Thread Justin Holmes
I think you misunderstand: I am not actually tracking llama herds. :-) This is just example code; I haven't actually tested it in the way that you suggest. The problem isn't with this code in particular, it's with this concept in general. This is a question I have had again and again in the past

Re: ORM Question

2014-04-02 Thread Bill Freeman
My point was that annotate might work after the other problems were fixed. Have you re-tested since? If your annotate still doesn't work then perhaps someone with more annotate experience than I will comment. On Wed, Apr 2, 2014 at 12:04 PM, Justin Holmes wrote: > No no, the annotate doesn't w

Re: ORM Question

2014-04-02 Thread Justin Holmes
No no, the annotate doesn't work - that's the whole reason for my question. See, the annotate doesn't associate instances with the annotated attribute, it associated results. (BTW, good looking out - I have once again fixed the SO question :-)) On Wed, Apr 2, 2014 at 10:17 AM, Bill Freeman wro

Re: ORM Question

2014-04-02 Thread Bill Freeman
1. You now have a foreign key to Herd, but you don't have a model by that name. It's called LlamaHerd. 2. I was misinterpreting what you wanted (couldn't get past the lack of a relationship while reading0. Once the relationship is fixed, your original annotate might work. On Tue, Apr 1, 2014

Re: ORM Question

2014-04-01 Thread Justin Holmes
You say "use the reverse relation manager in LlamaHerd to build up your annotation," but that answer the question. How can I sort LlamaHerd objects by the DOB of their largest llama? On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes wrote: > Yes, absolutely - my bad. I have updated to SO question.

Re: ORM Question

2014-04-01 Thread Justin Holmes
Yes, absolutely - my bad. I have updated to SO question. I meant the models to look like: class LlamaHerd(models.Model): shepherd = ForeignKey(User) class Llama(models.Model): size = FloatField() dob = FloatField herd = ForeignKey(Herd, related_name="llamas") On Tue, Apr 1,

Re: ORM Question

2014-04-01 Thread Bill Freeman
Aren't you missing a ForeignKey relationship to tell which LlamaHerd a Llama belongs to? Then you would use the reverse relation manager in LlamaHerd to build up your annotation. On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes wrote: > I have come across this problem in several Django projects, b

Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
As you say the raw sql always is the solution. But I take a few time to think how that could be possible with the ORM, and like akaariai says the prefetch_related get the values for de _default_manager. But if i defined a temporally manager that makes the only clausure it works, but i don't know

Re: ORM Prefetch related and only()

2013-05-29 Thread Christophe Pettus
On May 29, 2013, at 12:44 PM, Àlex Pérez wrote: > You know the way to simulate the behaviour that i want.? Raw SQL. At the point you are doing a multi-join query and selecting a subset of the fields to be returned, you probably should switch to raw SQL anyway. -- -- Christophe Pettus x...

Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
Ok thank's!!! but you thinks thats the normal behaviour? this could be included in future versions of the orm? You know the way to simulate the behaviour that i want.? 2013/5/29 akaariai > There is no way to alter the behavior of prefetch_related. It fetches > the related objects with the que

Re: ORM Prefetch related and only()

2013-05-29 Thread akaariai
There is no way to alter the behavior of prefetch_related. It fetches the related objects with the query defined by the related manager and that's it. - Anssi On 29 touko, 19:40, Àlex Pérez wrote: > I want to know if there is a way that the query that is executed to get the > prefetch related i

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-10 Thread Jani Tiainen
10.1.2013 8:59, Ian Kelly kirjoitti: On Wed, Jan 9, 2013 at 11:40 PM, Jani Tiainen wrote: If we just force using force_unicode everything works except in older versions of cx_Oracle (our server had 5.0.4 or something) connection strings can't be unicode for some reason. Sure, that's why the c

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Ian Kelly
On Wed, Jan 9, 2013 at 11:40 PM, Jani Tiainen wrote: > If we just force using force_unicode everything works except in older > versions of cx_Oracle (our server had 5.0.4 or something) connection strings > can't be unicode for some reason. Sure, that's why the check exists in the first place. Pr

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen
9.1.2013 19:21, Ian Kelly kirjoitti: On Wed, Jan 9, 2013 at 3:55 AM, Jani Tiainen wrote: Server is running Oracle Database 10g Release 10.2.0.5.0 - 64bit Production. (EE edition) and charset info: NLS_CHARACTERSETWE8ISO8859P1 NLS_NCHAR_CHARACTERSET AL16UTF16 Sorry, I meant your web

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Ian Kelly
On Wed, Jan 9, 2013 at 3:55 AM, Jani Tiainen wrote: > Server is running Oracle Database 10g Release 10.2.0.5.0 - 64bit Production. > (EE edition) > > and charset info: > NLS_CHARACTERSETWE8ISO8859P1 > NLS_NCHAR_CHARACTERSET AL16UTF16 Sorry, I meant your web server setup. -- You receive

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen
9.1.2013 12:28, Ian kirjoitti: On Wednesday, January 9, 2013 12:38:28 AM UTC-7, Jani Tiainen wrote: Tested against latest master. Same behaviour. In Oracle backend base.py is following piece of code: # Check whether cx_Oracle was compiled with the WITH_UNICODE option. This will

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Ian
On Wednesday, January 9, 2013 12:38:28 AM UTC-7, Jani Tiainen wrote: > > Tested against latest master. Same behaviour. > > In Oracle backend base.py is following piece of code: > > # Check whether cx_Oracle was compiled with the WITH_UNICODE option. > This will > # also be True in Python 3.0.

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-09 Thread Jani Tiainen
Ok, found source of the problem - but I don't know the solution. I'm using Oracle client 10.2.0.3.0. It seems that unicode doesn't work there. I compiled cx_Oracle against 11g instantclient 11.2 and it worked just fine. So it must be something that Django assumes with Oracle and unicode capa

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen
Tested against latest master. Same behaviour. In Oracle backend base.py is following piece of code: # Check whether cx_Oracle was compiled with the WITH_UNICODE option. This will # also be True in Python 3.0. if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 'UNICODE'):

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen
8.1.2013 21:00, akaariai kirjoitti: I created the following test case into django's test suite modeltests/ basic/tests.py: def test_unicode(self): # Note: from __future__ import unicode_literals is in effect... a = Article.objects.create(headline='0 \u0442\u0435\u0441\u0442

Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread akaariai
I created the following test case into django's test suite modeltests/ basic/tests.py: def test_unicode(self): # Note: from __future__ import unicode_literals is in effect... a = Article.objects.create(headline='0 \u0442\u0435\u0441\u0442 test', pub_date=datetime.n ow())

Re: ORM only/defer calls do not work on cross-table relations

2011-09-27 Thread John
Works perfectly, thanks :) Tested with a join 4 levels deep too and it made just one query. I use select_related elsewhere for more generic optimizations but it hadn't occurred to me that django would need the hint once in conjunction with an only() call. Perhaps a patch to ensure that the appro

Re: ORM only/defer calls do not work on cross-table relations

2011-09-27 Thread Alasdair Nicol
Hi John, Use select_related [1] to tell Django to 'follow' the foreign key. Try the following: testmodels = models.ATestModel.objects.all().select_related('other').only('other__name') print testmodels[0].other.name Regards, Alasdair [1]: https://docs.djangoproject.com/en/dev/ref/models/qu

Re: ORM help

2011-04-26 Thread Carl Meyer
Hi Daniel, On Apr 22, 5:57 pm, Daniel Gerzo wrote: > I have a following models: > > class Movie(models.Model): >      title = models.CharField(max_length=255) >      year = models.IntegerField(max_length=4) >      rating = models.DecimalField(max_digits=2, decimal_places=1, default=0) > > class R

Re: orm: operations between models fields

2011-03-21 Thread Tomasz Zieliński
On 19 Mar, 22:49, maxi wrote: > Hi, > > Which is the better way to do this on orm language ? > > select filed1, sum(field2 * field3) > from a_table > group by field1 > I believe this is not possible in the current Django ORM. It would need something like this to work: MyModel.objects.annotate

Re: ORM Query question

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

Re: ORM Query question

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

Re: ORM Query question

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

Re: ORM: get, filter and DoesNotExist

2010-04-04 Thread Russell Keith-Magee
On Mon, Apr 5, 2010 at 11:33 AM, zweb wrote: > after some debugging, just found out that > filter method does not throw DoesNotExist while get does. get() returns a single object. If a single object does not exist, you get a DoesNotExist exception. This is documented: http://docs.djangoproject.c

Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Well, I was bound to get something wrong :) > to_be_purged = > archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID', > flat=True) the end of the line should be .values_list('cacheID', flat=True) # not .values( Cheers Jirka -- You received this message becau

Re: ORM using tons of memory and CPU

2009-12-15 Thread Jirka Vejrazka
Hi, correct me if I got it wrong, but you essentially need these 4 things: 1) obtain the date for the the newest messages to delete 2) get cacheID of all objects to be deleted 3) delete the files 4) delete these objects from the database So, you could use something like this: # get the date

Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 03:35:29AM -0800, bruno desthuilliers spake thusly: > looks like settings.DEBUG=True to me. Nope. settings.py has DEBUG = False > wrt/ the other mentioned problem - building whole model instances for > each row - you can obviously save a lot of work here by using a > value

Re: ORM using tons of memory and CPU

2009-12-15 Thread Tracy Reed
On Tue, Dec 15, 2009 at 09:43:02AM +0200, Jani Tiainen spake thusly: > If you have DEBUG=True setting Django also records _every_ SQL query > made to database and depending on a case, it might use quite lot of > memory. My settings.py contains: DEBUG = False -- Tracy Reed http://tracyreed.org

Re: ORM using tons of memory and CPU

2009-12-15 Thread bruno desthuilliers
On 15 déc, 02:44, Tracy Reed wrote: > I have code which looks basically like this: > > now        = datetime.today() > beginning  = datetime.fromtimestamp(0) > end        = now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): >     """Delete archivedEmail objects from the beginning of time

Re: ORM using tons of memory and CPU

2009-12-15 Thread rebus_
2009/12/15 Tracy Reed : > > I have code which looks basically like this: > > now        = datetime.today() > beginning  = datetime.fromtimestamp(0) > end        = now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): >    """Delete archivedEmail objects from the beginning of time until >    

Re: ORM using tons of memory and CPU

2009-12-14 Thread Jani Tiainen
On Mon, 2009-12-14 at 17:44 -0800, Tracy Reed wrote: > I have code which looks basically like this: > > now= datetime.today() > beginning = datetime.fromtimestamp(0) > end= now - timedelta(days=settings.DAYSTOKEEP) > > def purgedb(): > """Delete archivedEmail objects from the

Re: ORM using tons of memory and CPU

2009-12-14 Thread fordprefect
Try using a) queryset.iterator() to iterate through the results and b) paginating the results. Otherwise you run the risk of loading all the results into memory at once, On Dec 15, 1:44 am, Tracy Reed wrote: > I have code which looks basically like this: > > now        = datetime.today() > beginn

Re: ORM

2009-10-08 Thread Geobase Isoscale
Hi all, Thanks a lot, for the comments. I'm working with PostgreSQL database together with with Django and GeoDjango. I intended to use views to query externally joined tables that keep changing based on the updates. I was also looking at database consistency by taking into account constraints with

Re: ORM

2009-10-08 Thread Mark (Nosrednakram)
Hello Isoscale, >  I intend to write ORM code that will create views and triggers in the > database? Which parts of the source code should I alter? I use django to access views commonly, primarily for reporting I'll create views taking care of the complex joins from our ERP so developers can eas

Re: ORM Cache in a standalone script

2009-10-08 Thread Alexis MINEAUD
Thanks a lot Karen, transaction was the problem. Resolved by : connection.cursor().execute('set transaction isolation level read committed') Have a nice day :) On Thu, Oct 8, 2009 at 1:52 PM, Karen Tracey wrote: > On Thu, Oct 8, 2009 at 5:07 AM, Alexis MINEAUD wrote: > >> Ok, my bad, the seq

Re: ORM Cache in a standalone script

2009-10-08 Thread Karen Tracey
On Thu, Oct 8, 2009 at 5:07 AM, Alexis MINEAUD wrote: > Ok, my bad, the sequence works well, i just confused the field name... > But the problem is still there if the update is done by another actor than > Django itself. > > My standalone script is daemon which poll my DB with a XX.objects.all()

Re: ORM

2009-10-08 Thread Matt Schinckel
On Oct 8, 6:18 pm, Marek Pietrucha wrote: > I see that all of you guy's know what your talking about. I was > thinking way won't you share some knowledge to this > topic:http://groups.google.com/group/django-users/browse_thread/thread/1517... > What does this have to do with this thread? You h

Re: ORM Cache in a standalone script

2009-10-08 Thread Alexis MINEAUD
Ok, my bad, the sequence works well, i just confused the field name... But the problem is still there if the update is done by another actor than Django itself. My standalone script is daemon which poll my DB with a XX.objects.all(). If i updated myself a row from XX, the daemon doesn't see the m

Re: ORM

2009-10-08 Thread Marek Pietrucha
I see that all of you guy's know what your talking about. I was thinking way won't you share some knowledge to this topic: http://groups.google.com/group/django-users/browse_thread/thread/1517053b51a1d7c8/ Please read and give some response. best regards. On Oct 7, 7:05 pm, Christophe Pettus w

Re: ORM Cache in a standalone script

2009-10-07 Thread Karen Tracey
On Wed, Oct 7, 2009 at 7:39 PM, laligatz wrote: > > Hi everybody. > > I'm stuck on a problem with the Django ORM. > After a basic query like select * from table where id = 1, the result > is still the same although i've update the row in the DB. > > Example: > > >>> Tag.objects.all() > [] > > >>>

Re: ORM

2009-10-07 Thread Christophe Pettus
On Oct 7, 2009, at 2:30 AM, Geobase Isoscale wrote: > I intend to write ORM code that will create views and triggers in > the database? Which parts of the source code should I alter? Django can work just fine with views and triggers, but the Django ORM layer will not create them for you. V

Re: ORM

2009-10-07 Thread Jani Tiainen
Geobase Isoscale kirjoitti: > I have to live with this reality, maybe in future we might develop a > code to extend Django to support views and triiggers. I don't get the use case here. What is this need for adding views and triggers? What purpose they serve for ORM? For database they're pre

Re: ORM

2009-10-07 Thread Geobase Isoscale
I have to live with this reality, maybe in future we might develop a code to extend Django to support views and triiggers. Many Thanks Isoscale --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: ORM

2009-10-07 Thread Russell Keith-Magee
On Wed, Oct 7, 2009 at 5:30 PM, Geobase Isoscale wrote: > Hi Everyone, >  I intend to write ORM code that will create views and triggers in the > database? Which parts of the source code should I alter? This is the third time you've asked the same question in less than a week. I answered the fir

Re: ORM

2009-10-07 Thread Jani Tiainen
Geobase Isoscale kirjoitti: > Hi Everyone, > > I intend to write ORM code that will create views and triggers in the > database? Which parts of the source code should I alter? None... There already exists mechanism to run arbitary SQL after syncdb... Or did you meant something else since I'

  1   2   >