Re: Is this what you would expect from this Q query?

2013-11-14 Thread akaariai
happens using both the original Q version > and using your suggested .exclude version. > Having found it I'm still not sure what it means or how to avoid it being > triggered! > > Any suggestions? > I believe the query is actually correct. The idea is that .exclude(con

Re: Complex query reduction

2013-11-07 Thread akaariai
On Friday, November 8, 2013 8:44:09 AM UTC+2, Robin St.Clair wrote: > > Anssi > > The last time I checked the use of IN, all the records from the database > in the query were brought back to the workstation, rather than being > processed on the backend and only the results returned to the workst

Re: Complex query reduction

2013-11-07 Thread akaariai
On Sunday, November 3, 2013 1:48:07 PM UTC+2, Robin St.Clair wrote: > > *IN* > >- if using Django avoid the IN operation at all costs > > > If there are potentially more than 15 items in the list, rework the IN as > a JOIN against whatever the source of the keys is > I don't necessarily agree

Re: Django 1.6 transactions witn multiple databases

2013-11-07 Thread akaariai
On Thursday, November 7, 2013 3:36:17 PM UTC+2, Vaal wrote: > > Hi > How to be in 1.6 with queries that involve multiple databases? > Previously recommended to create custom TransactionMiddleware. It was > convenient. Now TransactionMiddleware is deprecated. > You can set ATOMIC_REQUESTS per data

Re: Complex query reduction

2013-11-03 Thread akaariai
You should rewrite the query into a form that doesn't require distinct. In general, when you see a query that has joins and DISTINCT, that should be an alarm bell that something isn't written correctly in the query. Unfortunately Django's ORM generates such queries, and that isn't easy to fix a

Re: Complex query

2013-09-09 Thread akaariai
On Monday, September 9, 2013 12:13:09 AM UTC+3, Yegor Roganov wrote: > > I found out this is a so called "top n per group" problem and it's not > that easy to implement in django. Maybe someone could help me to find > another way (for example, alter the schema in some way)? > This is something t

Re: What's the new "field" parameter in the ManyToOneRel __init__ function?

2013-09-07 Thread akaariai
On Saturday, September 7, 2013 6:52:14 AM UTC+3, Mark Young wrote: > > For a little bit of context, here's an example of code that perviously > worked but now doesn't: > > class CategoryAdminForm(forms.ModelForm): > """Form for Category's Admin""" > parent = TreeNodeChoiceField( > labe

Re: .filter() and .exclude() don't add up

2013-07-30 Thread akaariai
On Tuesday, July 30, 2013 6:26:47 PM UTC+3, Daniele Procida wrote: > > On Mon, Jul 29, 2013, akaariai > wrote: > > >> I understood that part. But by "more general" I mean one that will work > >> for any case, without having to know where the Nulls might

Re: invalid reference to FROM-clause entry for table

2013-07-30 Thread akaariai
On Tuesday, July 30, 2013 6:40:27 AM UTC+3, hippomoe wrote: > > I'm using djorm-ext-pgfulltext extension to do full-text-search using > Postgres on a title field for one of my models (Bookmark). > > class Bookmark(TimeStampModel): > title = models.CharField(max_length = 100) > # other fi

Re: .filter() and .exclude() don't add up

2013-07-29 Thread akaariai
On Sunday, July 28, 2013 10:44:49 AM UTC+3, Daniele Procida wrote: > > On Sat, Jul 27, 2013, Steve McConville > > wrote: > > >Perhaps I'm not sure exactly what you mean by "more general", but I > >was recommending something like > > > >red_things = queryset.filter(Q(color="red")) > >non_red

Re: Creating database views, functions, stored procedures etc

2013-06-20 Thread akaariai
On 20 kesä, 14:32, Mark Robson wrote: > Hi, > > I've got a Django application which uses a mixture of managed and unmanaged > models. > > The managed models get their tables created in the usual way, the unmanaged > ones via a number of .sql files in the application/sql directory. > > This works f

Re: Django foreing keys joins

2013-06-09 Thread akaariai
On 6 kesä, 02:05, Àlex Pérez wrote: > Can someone tell me why the or in that query: > print Counter.on_medicos.filter(loc__isnull=True).only("id").query > > ""SELECT `web_counter`.`id` FROM `web_counter` LEFT OUTER JOIN > `locations_localidad` ON (`web_counter`.`loc` = `locations_localidad`.`id`)

Re: Is it possible to add SQL comments to a query built with the ORM?

2013-05-30 Thread akaariai
There is no public API way. You can likely do this with .extra(): Object.objects.filter(Q(pub_date__lte=datetime.now)).extra(where=['1=1 / * query no. 123 */']) - Anssi On 30 touko, 12:42, Timo Josten wrote: > Hint: This is a cross-post > fromhttp://stackoverflow.com/questions/16831162/is-it-p

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: Object Lookup after Save

2013-05-28 Thread akaariai
On 29 touko, 01:07, Chris Conover wrote: > Adding commit_unless_managed() before the get() seems to fix the problem. > Looking at it locally, the Gearman worker starts a transactions and just > calls commit when the processing is done, over and over, never starting a > new transaction. That combin

Re: Object Lookup after Save

2013-05-28 Thread akaariai
On 28 touko, 22:20, Chris Conover wrote: > Well, you can inspect the object and see it's primary key. Surely that > means the INSERT is completed? So the workflow goes like this: > > foo = Foo() > foo.save() > foo.pk # new primary key is available > submit_gearman_task(foo.pk) > > Then in the Gear

Re: Testing with complex database setups

2013-05-24 Thread akaariai
On 23 touko, 15:09, Jani Tiainen wrote: > Hi, > > I've product that uses complex setup scripts - tens of SQL scripts that > creates tables, views, complex triggers, grants permissions and such and > finally populates database with some pre-data. > > So how I should proceed with unit testing with

Re: Django's cascade delete is executing the DELETE SQL twice

2013-05-24 Thread akaariai
On 22 touko, 18:57, Michael wrote: > I've got an odd situation here, any idea why the delete SQL for the > `myapp_entry_tag` table is being performed twice? > > >>> from myapp.models import Tag > >>> from django.db import connection > >>> from pprint import pprint > >>> Tag.objects.only('pk').get(

Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-05-21 Thread akaariai
ginal regression that would be very useful in ensuring the regression is really solved. - Anssi On 19 huhti, 02:06, akaariai wrote: > On 18 huhti, 22:07, Greg H wrote: > > > Running into a similar issue on my own project, seems to be when you try an > > cache a model which ha

Re: How to check for a specific field change in a model?

2013-04-18 Thread akaariai
On 18 huhti, 20:34, deepankar bajpeyi wrote: > I have my models.py : > > class Hotel(models.Model): >     name = models.CharField(max_length=20) >     currency = models.ForeignKey(Currency) > > class Currency(models.Mode): >     code = models.CharField(max_length=3) >     name = models.CharField(m

Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-04-18 Thread akaariai
On 18 huhti, 22:07, Greg H wrote: > Running into a similar issue on my own project, seems to be when you try an > cache a model which has a related model which in turn has a many to many > field. So for example, I have an instance of a Student, which has a > ForeignKey to Book, which in turn has a

Re: field lookups problem

2013-03-22 Thread akaariai
On 22 maalis, 15:44, Roberto López López wrote: > Hi, > > I have a problem with my data model while doing field lookups. This is > my models.py: > > from django.db import models, IntegrityError > > # Create your models here. > > class Model1(models.Model): >     title = models.CharField(max_length

Re: Django & Oracle connection problem

2013-01-24 Thread akaariai
On 25 tammi, 00:27, Dylan Klomparens wrote: > I have a Django program that is connecting to an Oracle database. In my > settings.py file I have this configuration: > > DATABASES = { >   'default': { >     'ENGINE': 'django.db.backends.oracle', >     'NAME': 'xe', >     'USER': 'MY_USER_NAME', >  

Re: Global filtering of the querystes

2013-01-22 Thread akaariai
On 22 tammi, 08:32, Jani Tiainen wrote: > Hi, > > I've several models that share same attribute and form doing ajax > queries to/from form in a browser window. > > For example owner: > > class MyClass(models.Model): >      title = models.TextField(max_length=100) >      owner = models.TextField(ma

Re: Correct way to specifiy database-level column defaults

2013-01-11 Thread akaariai
On 10 tammi, 16:04, john.wolt...@tpiengineering.com wrote: > What is the best way to specify a database level default value with > Django?  If I want a timestamp column to default to the SQL function now(), > is there an accepted way to make it happen?  Or to default a boolean column > to True?  I

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: Get objects sorted by time of last comment

2013-01-05 Thread akaariai
On 5 tammi, 06:41, Vibhu Rishi wrote: > Hi Anssi, > > Thanks for the comment. > > I was thinking that if I have to do the last comment hackery for all the > objects would it also work if I > * add a last_comment_time field to the models I use with comments. > * modify the comment form ( not sure w

Re: Get objects sorted by time of last comment

2013-01-02 Thread akaariai
On 2 tammi, 08:50, Vibhu Rishi wrote: > Hi All, > > A very happy new year to you all ! > > I am working on a website I am making as my hobby project. It is to do with > motorcycle touring. > > I have done some initial work on it, and incrementally making changes as > and when I can. > > I am tryin

Re: Bulk delete - performance / object collection

2013-01-02 Thread akaariai
A note about the upcoming 1.5: The delete() was optimized so that it doesn't fetch the objects if it doesn't have to. The "doesn't have to" translates to: - no delete signals defined for the model - no cascades That being said using DSE might be the right choice for you. - Anssi On 2 tammi, 1

Re: The method all() in overrided models.Manager doesn't works as expected

2012-12-31 Thread akaariai
Interesting approach :) Some pointers: - The Page object has an automatic primary key. You should probably change the path to be the primary key. - .all() should not return a list of objects, instead it should return a QuerySet which returns a list of objects when iterated. You might be bette

Re: memory leak? Am I taking crazy pills?

2012-11-23 Thread akaariai
On 22 marras, 08:27, Dan Ancona wrote: > python 2.7.3, django 1.4.2 > > Our app (a fairly simple tastypie API that runs some machine learning foo on > mongodb records) is deployed to heroku and is leaking memory at a pretty good > clip. Hitting heroku memory errors after about an hour or two,

Re: IntegrityError at /add/ PRIMARY KEY must be unique

2012-09-27 Thread akaariai
.create() creates the object into DB, then .save(force_insert=True) tries to insert the same object with the same ID again -> integrity error. Seems like you don't need the second save at all. - Anssi On 27 syys, 15:39, Amyth Arora wrote: > Not quite sure, but it seems like the save() method is

Re: database error and connection._rollback

2012-08-22 Thread akaariai
On 23 elo, 08:30, Mike Dewhirst wrote: > This ... [1] > > from django.db import connection > connection._rollback() > > ... solved a problem for me in unit testing when I catch a deliberate > DatabaseError. > > Django 1.4 > Python 2.7 > PostgreSQL 9.1 > > My question: Is it safe enough to use a me

Re: From Django 1.1 to Django 1.3.1 - Goes Very Slow

2012-08-22 Thread akaariai
On 21 elo, 19:04, ydjango wrote: > Thank you Paul. I will use those tools. > > I also plan to replace to some ORM queries by raw sql to avoid performance > impact of cloning and multi db enhancements. If you can, please try to pinpoint the reason for regressions, and if it seems to be in Django's

Re: Calculations in Queries

2012-08-16 Thread akaariai
On 16 elo, 03:51, Callum Bonnyman wrote: > I've tried a few things but i cannot get the correct date formats to > calculate the difference, so far i have this: > >     popular_posts = Post.objects.extra(select={ >     'popularity': '(' + datetime.datetime.now() + ' - created) * views' >     }) >

Re: union of two QuerySets

2012-08-01 Thread akaariai
On 1 elo, 19:15, Tim Chase wrote: > On 08/01/12 10:28, lex P rez wrote: > > > Hi, > > > it's better  Person.objects.filter(models.Q(first_**name__startswith='mic'), > > models.Q(first_**name__startswith='joh')) > > (only one query...) > > I'm pretty sure this will get you the intersection (it uses

Re: MySQL total overheat (somewhat complex database)

2012-07-28 Thread akaariai
On 28 heinä, 21:44, lubos wrote: > Hello, > > I have a quite sophisticated database with frequently interconnected tables > and on the top level table, Django produces queries like this: > > SELECT `data_schedule`.`id`, `data_schedule`.`process_id`, > `data_schedule`.`hardware_id`, `data_schedule`

Re: Is this possible using the Django ORM without raw SQL?

2012-07-28 Thread akaariai
On 28 heinä, 15:39, sbrandt wrote: > > On 28 heinä, 12:20, sbrandt wrote: > > > Hello, > > > > for the first time ever how to compile a query with the Django ORM :/ > > > > There are two Models: The second model has a foreign key to the first > > model > > > and a type, where the combination of "

Re: Is this possible using the Django ORM without raw SQL?

2012-07-28 Thread akaariai
On 28 heinä, 12:20, sbrandt wrote: > Hello, > > for the first time ever how to compile a query with the Django ORM :/ > > There are two Models: The second model has a foreign key to the first model > and a type, where the combination of "first model and second model's type" > is unique. Let's say

Re: Prefetch related data when using raw()

2012-07-26 Thread akaariai
On 26 heinä, 19:12, Sencha wrote: > I want to prefetch related data (ideally through the > prefetch_related()method), however I need to use the > raw() mapper method that will map a custom query (complicated table joins > to filter my query properly) to my model. However when I try this I get: >

Re: Excluding items from a queryset

2012-07-16 Thread akaariai
On 16 heinä, 14:38, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I have a queryset of categories and would like to exclude categories with > no items associated. I am cycling through the queryset as follows, without > the desired result: > > for cat in categories: >                 if cat.ite

Re: Ranking Queryset

2012-06-20 Thread akaariai
On 20 kesä, 20:37, Peter Ung wrote: > Thanks  Chris for your response; however, its not the solution I'm looking > for. I need the ranking to go in sequential order - the solution you > provided will just make my points, or scores in your example, the rank. I > need, for example, the person with t

Re: django 1.4 memory issues

2012-06-14 Thread akaariai
On 12 kesä, 17:59, Greg Donald wrote: > Over the weekend I upgraded my project to Django 1.4.  After the > upgrade my Apache/mod_wsgi setup began running out of memory.  I > increased the memory capacity of my virtual servers, but that only > extended the time until they began to swap again.  I fo

Re: How postgres data type "real" is represented in Django?

2012-06-14 Thread akaariai
On 12 kesä, 18:50, IgorS wrote: > Hi ALL! > > It seems that there is no class in Django models that represents 4-byte > data type "real" in postgres. I looked into > django\db\backends\postgresql_psycopg2\creation.py but could not find it > there. The only choice seems to be FloatField, which repr

Re: How to perform a simple search ignoring characters with accents (á, é, í, ó, ú)

2012-06-05 Thread akaariai
On Jun 4, 4:20 pm, Peter of the Norse wrote: > One possibility is to use MySQL. By default it indexes things so that a, á, > and À are the same thing. There are some gotchas though: you have to make > sure that it’s using an appropriate character set for the languages you’re > using. (UTF-8 is

Re: Is this requirement feasible with django

2012-06-03 Thread akaariai
On Jun 3, 11:02 am, Kalpa Welivitigoda wrote: > Hi, > > I want to develop a web based laboratory test reporting system. It > basically involves storing the records of different tests for > different patient and get a print out of the reports. There are around > 100 tests with different fields. > >

Re: Oracle schema not working

2012-06-02 Thread akaariai
On Jun 1, 12:58 pm, Jani Tiainen wrote: > > Hello. The user connecting to Oracle is an ordinary user and needs to > > prefix all tables with the schema name. > > I've tried crafting Meta.db_table like so: > >http://cd-docdb.fnal.gov/cgi-bin/RetrieveFile?docid=3156&version=1&fi... > > > But I get e

Re: Struggling with formsets

2012-05-29 Thread akaariai
On May 29, 12:45 pm, David wrote: > Anyone else have any suggestions please? > > Thank you I don't think there is a way to create formsets, and then formsets related to the first formsets. So, something like this is what you likely need: for p in persons: do_what_you_did_for_single_object()

Re: Set additional conditions for JOIN

2012-05-28 Thread akaariai
On May 28, 10:59 pm, Boris Shemigon wrote: > Hi, > > I wonder is there a way to generate a query with joins with more than one > condition? For example: > > SELECT o.id FROM object > JOIN object_value AS ov1 ON ov1.o_id=object.id AND ov1.field_id=1 AND > ov1.value=2 > JOIN object_value AS ov2 ON o

Re: Multiprocess Queryset memory consumption increase (DEBUG=False and using iterator)

2012-05-28 Thread akaariai
On May 28, 5:42 pm, pc wrote: > I am stumped. I am trying process a lot of data (2 million records and > up) and once I have a QuerySet, I immediately feed it to a > queryset_iterator that fetched results in chunks of 1000 rows each. I > use MySQL and the DB server is on another machine (so I don'

Re: Why this database error in shell? (Query looks valid to me.)

2012-05-26 Thread akaariai
On May 26, 10:26 pm, Chris Seberino wrote: > I have Homework objects that are related to Course objects for a > school related Django app.  I can access Course and Homework objects > but there is one Homework query at the end of this email that bombs > and I don't know why. > > ===

Re: ordering m2m query based on through table

2012-05-24 Thread akaariai
On May 23, 11:33 pm, akaariai wrote: > On May 23, 3:36 pm, akaariai wrote: > > > I guess (again!) that the reason for the LEFT JOIN is this call in sql/ > > compiler.py:_setup_joins() > > > self.query.promote_alias_chain(joins, > >      self.qu

Re: ordering m2m query based on through table

2012-05-23 Thread akaariai
On May 23, 3:36 pm, akaariai wrote: > I guess (again!) that the reason for the LEFT JOIN is this call in sql/ > compiler.py:_setup_joins() > > self.query.promote_alias_chain(joins, >      self.query.alias_map[joins[0]].join_type == self.query.LOUTER) > > This seems to prom

Re: ordering m2m query based on through table

2012-05-23 Thread akaariai
On May 23, 2:36 pm, bruno desthuilliers wrote: > > The interaction between > > multiple references to same reverse foreign key relation in single > > queryset is somewhat hard to remember. Could you post the generated > > SQL? > > here you go - reformated for readability: > > SELECT >   `blookcore

Re: Following multiple reverse relationships

2012-05-23 Thread akaariai
On May 23, 3:06 pm, sk <6b656...@gmail.com> wrote: > > On May 22, 12:51 pm, sk <6b656...@gmail.com> wrote: > > > > If I have a hierarchy of models such that: > > > > class A(models.Model): > > >     name = CharField(max_length=10) > > > > class B(models.Model): > > >     name = CharField(max_length

Re: ordering m2m query based on through table

2012-05-23 Thread akaariai
On May 23, 12:12 pm, bruno desthuilliers wrote: > On May 22, 4:34 pm, akaariai wrote: > > > So, you would want to do collection.songs.all() and have that ordered > > by the sequence defined in the m2m table? I agree - this seems to be > > somewhat hard currently. > &

Re: "Connection refused" with backend psycopg2

2012-05-23 Thread akaariai
On May 23, 11:46 am, Tanuva wrote: > If I connect manually using psql, I automatically get an ssl connection. > Non-ssl isn't supposed to work in this case. Removing the sslmode from > the django config doesn't change anything as I noted in the paste. > > > The error you are getting is the same yo

Re: "Connection refused" with backend psycopg2

2012-05-22 Thread akaariai
On May 23, 8:41 am, Tanuva wrote: > Am 22.05.2012 23:52, schrieb akaariai: > > > > > > > > > > > On May 22, 11:51 pm, Tanuva wrote: > >> Moin, > > >> lately, I wanted to switch my database from the testing sqlite file to a > >&

Re: After python upgrade, User.objects.get(username= doesn't work consistently

2012-05-22 Thread akaariai
On May 22, 11:49 pm, Hanne Moa wrote: > I upgraded python to 2.6.8 today from an earlier 2.6, what an > adventure! So much bizarre happenings so many places. Tonight's > special: > > SomeModel.objects.get(sometextfield=sometext) always works (when there > is one entry where sometextfield=sometext

Re: "Connection refused" with backend psycopg2

2012-05-22 Thread akaariai
On May 22, 11:51 pm, Tanuva wrote: > Moin, > > lately, I wanted to switch my database from the testing sqlite file to a > more productive pgsql 8.4 server. Now I'm constantly getting a > "connection refused" from the psycopg2 backend:http://dpaste.org/0Ezka/ > Database configuration:http://dpaste.

Re: DB joining 3 tables in django admin, while searching on the primary table

2012-05-22 Thread akaariai
On May 22, 5:10 pm, Derek wrote: > Please read > this:https://code.djangoproject.com/wiki/UsingTheMailingList#Donts: > before continuing to post these types of messages. In addition, doing a "django prefetch_related" search on Google might lead to some clues here... - Anssi -- You received t

Re: ordering m2m query based on through table

2012-05-22 Thread akaariai
On May 22, 7:14 am, KentH wrote: > I am trying to configure a m2m relationship to be ordered based on data in > the through table. I assumed an 'order' attribute in the through-table's > Meta class would be honored, but it's not. Bug #11850 (closed: wontfix) > relates to this problem, but with no

Re: Following multiple reverse relationships

2012-05-22 Thread akaariai
On May 22, 12:51 pm, sk <6b656...@gmail.com> wrote: > If I have a hierarchy of models such that: > > class A(models.Model): >     name = CharField(max_length=10) > > class B(models.Model): >     name = CharField(max_length=10) >     a= ForeignKey(A) > > class C(models.Model): >     name = CharField

Re: What persists in memory across requests?

2012-05-18 Thread akaariai
aneously, but Python poolers are restricted to seeing one processes at a time. Still, if you want to experiment on poolers in Python code, I have written a couple of attempts for a connection pool you can use as bases of your work. https://github.com/akaariai/django-psycopg-pooled and https://githu

Re: Thread safety with view arguments in class based views

2012-05-17 Thread akaariai
On May 18, 12:17 am, Rafael Durán Castañeda wrote: > I'm wondering if this is suitable for a doc bug report, it is? I think a direct github pull request is the way to go. And yes, the docs could be clarified here. - Anssi -- You received this message because you are subscribed to the Google G

Re: Model design question

2012-05-17 Thread akaariai
On May 18, 5:25 am, oneroler wrote: > Thanks Mike, that is what I was originally planning to do but realized > there would be situations where that wouldn't do exactly what I wanted. > For example, if there is a business that only has the strategy 'wholesale' > assigned, using ForeignKey would sti

Re: Deferred fields problem.

2012-05-14 Thread akaariai
On May 14, 3:29 pm, Jani Tiainen wrote: > 14.5.2012 14:50, akaariai kirjoitti: > > > > > > > > > > > > > On May 14, 2:37 pm, Jani Tiainen  wrote: > >> Hi, > > >> I have in my database quite a bunch of a models where I do have qui

Re: database routers from html code

2012-05-14 Thread akaariai
On May 14, 11:43 am, Antonimus wrote: > Hi, I'm new to django and web framework. What I'm trying to do is to > select what database to connect from html template select. In the > login form, besides user and password, it's a select field with > database alias to connect: >       >       {% for db

Re: Deferred fields problem.

2012-05-14 Thread akaariai
On May 14, 2:37 pm, Jani Tiainen wrote: > Hi, > > I have in my database quite a bunch of a models where I do have quite > large fields and I'm using .only('pk', 'identifier') to fetch only those > two fields - mainly to make serverside natural sort for a data. Database > is legacy one and it's b

Re: postgresql connection is not closed

2012-05-14 Thread akaariai
On May 14, 9:05 am, shariq wrote: > Hi, > I am running django-1.2 with postgresql. > I am facing the problem. > Django is not closing the connection and the connection is > retained by db-server until DBA goes and kill the connection manually. Are you using multiple databases? Is this happening i

Re: Django psycopg error

2012-05-13 Thread akaariai
> On Friday, May 11, 2012 3:58:07 PM UTC-4, akaariai wrote: > > > On May 11, 7:37 pm, Mike Di Domenico > > wrote: > > > I have the python-psycopg2 package installed and the settings for my > > engine > > > are 'django.db.backends.postgresql_psycopg2&

Re: Django unit test. Access the 'real data base'

2012-05-11 Thread akaariai
On May 11, 4:38 pm, Gelonida wrote: > For one unit test I would like to use the real data base and not the > test data base. > > Basically this unit test shall verify that the server database fulfills > certain consistency criterea. > > How can I write one django test, that uses the 'default' (non

Re: Django psycopg error

2012-05-11 Thread akaariai
On May 11, 7:37 pm, Mike Di Domenico wrote: > I have the python-psycopg2 package installed and the settings for my engine > are 'django.db.backends.postgresql_psycopg2' and I am still getting the > error. > > When I do "python manage.py shell" I get the error "Error: No module named > psycopg". >

Re: Django timezone doesn't show the right time?

2012-05-01 Thread akaariai
b_date()* > > Traceback (most recent call last): >   File "", line 1, in > AttributeError: type object 'Poll' has no attribute 'pub_date' > > Here's a better overview of what my relevant files looks like and what > setup I have tried to use.  Maybe it w

Re: Django timezone doesn't show the right time?

2012-05-01 Thread akaariai
On Apr 30, 11:03 pm, Dan Santos wrote: > Hi I'm a total programming newbie! > > ### INTRO ### > I have been following this tutorial and the timezone outputs confuses > me.https://docs.djangoproject.com/en/1.4/intro/tutorial01/#playing-with-... > > And I'm still confused after reading these explana

Re: Slow page in admin

2012-04-25 Thread akaariai
On Apr 25, 4:22 pm, Jonas Ghyllebert wrote: > Hi, > > Thanks for the quick reply. > > when we test the application local, it works like a charm. > But when we deployed it on Google App engine using Cloud SQL, the > application works now and then and this particular page is much slower than > the o

Re: Slow page in admin

2012-04-25 Thread akaariai
On Apr 25, 3:35 pm, Jonas Ghyllebert wrote: > I'm new to Django and I would like to apologize if it's been asked before. > > I have two models *Region *and *Zip*. In the admin system, Zip is an inline > model in Region > > Whenever i want to add a Region it shows directly 25 listboxes with zips. >

Re: Django DateTimePicker only shows up for superusers inside my app

2012-04-24 Thread akaariai
Could you check if the non-admin user can download this script: "/ admin/jsi18n/". It seems downloading that script needs privileges to access admin site. That view just provides the javascript catalogs for "django.conf" and "django.contrib.admin" packages. You can provide them from different URL,

Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Apr 23, 6:54 pm, "Daniel Sokolowski" wrote: > +1 > > I use SQlite3 on lower traffic production sites due to it's ease of install > and deployment. Even though I only once I reached this 1000 variable limit I > would like to see some django work around. I thought a little more about this, and I

Re: Problem with get_or_create

2012-04-23 Thread akaariai
On Apr 23, 4:26 pm, Murilo Vicentini wrote: > Hey guys, > I'm having a bit of a problem using the get_or_create with a > ManyToManyField in my model. > class Run(models.Model): >         distros = models.ForeignKey('Distro') >         compilers = models.ManyToManyField('Compiler', blank=True, > nu

Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Apr 23, 10:48 am, Lukas Zilka wrote: > Hey Russ, > > thanks for your reply. I looked at the bulk insertion problem, and > that made me think that probably using the variables themselves is the > problem. It does not really make sense to me why anybody bothers to > use variables in a long SQL

Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Apr 23, 1:43 pm, Javier Guerra Giraldez wrote: > On Mon, Apr 23, 2012 at 3:58 AM, akaariai wrote: > > The last one, qs.filter(id__in=large_list) is pretty much impossible to fix. > > what's wrong with: > > qs.filter((Q(id__in=large_list[:n])|Q(id__in=large_lis

Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Monday, April 23, 2012 1:56:19 AM UTC+3, Russell Keith-Magee wrote: > > It's also probable that it's something that is new to 1.4 (or, at least, > that it manifests in slightly different ways in 1.4). One of the features > added in 1.4 is bulk insertion of data. This means that you can use a

Re: Django help required with non foreign key relations

2012-04-23 Thread akaariai
On Apr 23, 8:15 am, Aditya Sriram M wrote: > Ohh this looks little promising.. > > However, > >    1. I need a few cols of table1 and few from table 2 to be displayed. How >    can we achieve that at the .filter() level? and >    2. At the view level like using the list_display () for displaying t

Re: Django help required with non foreign key relations

2012-04-22 Thread akaariai
On Apr 22, 1:31 pm, Aditya Sriram M wrote: > File myapp/models.py has this sample code.. > > from django.db import models > > # model for 'user' table in database oracle_dbuser1:user > class User(models.Model): >     . . . >     customerid = models.BigIntegerField() > > # model for 'customer' tabl

Re: 'builtin_function_or_method' object has no attribute 'split' after upgrading to Django 1.4

2012-04-22 Thread akaariai
On Apr 22, 4:45 am, Taras_96 wrote: > Hi, > > I've just upgraded to Django 1.4, and I was getting a > 'builtin_function_or_method' object has no attribute 'split' error > being thrown. I traced this down to an erroneous use of distinct, I > had: > > X.objects.distinct(id) > > Which had previously

Re: image KeyError

2012-04-21 Thread akaariai
On Apr 21, 11:30 pm, psychok7 wrote: > hi there , so i am not sure if i am doing this the right way, but > im successfully able to upload files(images) and store them in my defined > folder  and the link in my mysql  database. >  the error comes when i try to return the image with the HTTP RESPONS

Re: Modeling Question on Many-to-Many(with through) and Proxy models

2012-04-21 Thread akaariai
On Apr 21, 8:35 pm, Arruda wrote: > Should I create this many-to-many table as a normal model(no proxy) and set > the foo foreingkey to Foo1 instead of Foo? > Or should I use only FooBar as many-to-many and create some specific > queries that would convert ALL the returned foo objects as Foo1 inst

Re: Django 1.4, Postgresql and partitioned table

2012-04-18 Thread akaariai
On Apr 18, 3:49 pm, Michaël Journo wrote: > Well you were right. The insert didn't return the id, so that was the > problem. > > I used your trick (customizing the save method) and it seems to work > just fine. Glad it helped. A mandatory warning: you are using non-public parts of Django's backe

Re: How to release the caching of QuerySet

2012-04-18 Thread akaariai
On Apr 18, 2:48 pm, Kejun He wrote: > (2) > About the query if be executed > > if the code like below, and do no operation on variable tmp:>>>tmp = > Demo.objects.filter(pid=p_id) > > The query would not be executed actually untill do some operation on > tmp(exp:tmp.count()) > > if just do "Demo

Re: How to release the caching of QuerySet

2012-04-18 Thread akaariai
On Apr 18, 1:05 pm, Kejun He wrote: > and define a method named test in views.py. like below: > > def test(p_id): >     # Just execute the filter 1000 times >     for i in xrange(1000): >         Demo.objects.filter(pid=p_id) > > run the test function again:>>>test(1) > > The occupied memory i

Re: Django 1.4, Postgresql and partitioned table

2012-04-17 Thread akaariai
The problem seems to be that INSERT INTO partitioned_table values(...) RETURNING ID isn't for some reason returning the ID. Can you confirm this is the case by running the insert query manually from dbshell? I believe 1.3 used SELECT currval(pg_get_serial_sequence('partitioned_table', 'id')) inste

Re: Django ORM - query help

2012-04-12 Thread akaariai
On Apr 12, 4:01 pm, David wrote: > The above ORM statement however does not look as elegant to read as I have > come to expect from Django though. The resulting SQL doesn't seem too > shabby however. .distinct(fields) + .order_by() is pretty low level stuff - that is why it would be nice if there

Re: Django ORM - query help

2012-04-12 Thread akaariai
On Apr 12, 11:52 am, David wrote: > > Hi Jani > > > That was very helpful. Is there a way to include select_related into that > > query? or do I have to list every single field I would like to return using > > values()? > > > last_deleted = ModificationLog.objects.values('thing__id', ' > > thing__

Re: PostgreSQL Introspection Bug

2012-04-11 Thread akaariai
On Apr 11, 4:39 pm, Thomas Guettler wrote: > I fixed a postgreSQL introspection bug, but unfortunately it is still in > stage "new". > > Can someone please review it? > >    https://code.djangoproject.com/ticket/17785 I hope to find time to look at this. No promises, but added to my rather long

Re: Django Model - create a filter and use it as argument

2012-04-04 Thread akaariai
On Apr 5, 1:00 am, Ivo Marcelo Leonardi Zaniolo wrote: > Hi there, > > I'm need to pass a QuerySet as an argument, like a function pointer that > will be > evaluate in other time. Somebody has one idea how I can do this? > I dont want to create a "box" method to encapsulate it. > > So, can anyone

Re: custom manager to control access

2012-04-04 Thread akaariai
On Apr 4, 3:15 am, Mike Dewhirst wrote: > I have now discarded the idea :) > > I'm not very comfortable with thread locals. I need a bullet-proof > approach which makes data from other companies invisible to members of > this company. I suppose a view decorator is the way to go but I would > have

Re: AttributeError at /admin/coltrane/entry/add/ 'Entry' object has no attribute 'pubdate'

2012-04-04 Thread akaariai
Do you get a stacktrace from the error? You should get one, and it should point out the code-path to the erroneous pubdate usage. If you do not get one for one reason or another, search your project for the string "pubdate" and go through all locations containing that string. The code snippets you

Re: Django database-api

2012-04-03 Thread akaariai
On Apr 3, 11:27 am, KasunLak wrote: > Hi, > > No, sorry for not giving more details. What I am asking is once we > syncdb the generated scripts (create table). Can we see the method > implementation of database access api? > > For example: If we have created and deployed a model called Poll > (tut

Re: Filtering results before & after update?

2012-04-01 Thread akaariai
On Apr 1, 4:24 am, symmitchry wrote: > I have a straightforward form that simply reduces an item count by 1, for a > selected product. (The form essentially "ships" a product, so need to > decrease remaining term_length by 1). > > I have the following code: > >             cd = form.cleaned_data

  1   2   3   >