Re: Track "before" and "after" state of an object when editing in the Admin?

2010-04-28 Thread Euan Goddard
Hi Derek, > How and where can this be done? I've recently been developing a project that uses MongoDB to audit Django models. I've just published an early version of this work on launchpad: https://launchpad.net/django-audit/ I haven't got around to writing any documentation yet, but if you're ke

Re: django_audit 0.0.2

2010-05-04 Thread Euan Goddard
On May 1, 4:00 am, Dj Gilcrease wrote: > Ya I saw the announcement on it the day I pushed my code to google, > hence my remark about not being tied to a "NoSQL" solution. I had > already created the project name by the time I saw the announcement so > just went with it This is all very well, but

Re: django_audit 0.0.2

2010-05-05 Thread Euan Goddard
On May 4, 11:21 am, Dj Gilcrease wrote: > Google code wont let me change the project name without deleting and > recreating the project so I just added a note to the top That is quite annoying. I hope you can find a good solution to that problem. > "This is a fairly comprehensive Audit Trail App

Re: where can I find good unit test examples?

2010-05-06 Thread Euan Goddard
Hi Chris, First of all, I never had much luck writing reproducible tests for Django models with the fixture system that comes built into Django as I never got consistent results and found the XML a pain to maintain. I came across Fixture - http://code.google.com/p/fixture/ We have this running wit

Re: how to avoid "in" query for large sets?

2010-05-24 Thread Euan Goddard
I've found the best way to solve these problems is to use a values_list queryset and inject the result of the into the outer query. Django is smart and doesn't actually evaluate the values_list query and instead injects that as a sub query in the SQL. However in this case can't you simply do: Use

Re: Annotating a queryset without aggregation

2010-05-28 Thread Euan Goddard
Hi Tom, Whilst Django annotation is great, it is rather simplistic in nature and can only do very basic Count, Sum, Avg, etc. which do not allow any filtering (i.e. a WHERE clause in the SQL). Unless there are major differences in 1.2 (which I haven't seen) then you won't be able to do what you w

Re: best approach to solve statistical problem

2010-05-28 Thread Euan Goddard
Darren, This seems like quite a complex problem and I'm not sure whether the Django ORM would be up to it. I've had a lot of trouble when using multiple annotations on Querysets when JOINs are involved as Django does the wrong thing. Have you considered using a schemaless DB like MongoDB for your

Re: Get pk before commit

2010-05-29 Thread Euan Goddard
Hi, Could you explain the situation in a little more detail as I don't quite follow what you mean. As far as I'm aware if you have something like the following: >>> my_inst = MyModel(foo="bar", ...) >>> my_inst.save() You'll have the pk at this point even if the transaction hasn't been committed

Re: Having to rstrip the " [] " from the end of your Key when posted?

2010-05-29 Thread Euan Goddard
Yeah jQuery added this annoying "feature" in 1.4. There's no "nice" way around it other than to recognise that any JS arrays will have this suffix. Euan On 29 May, 05:33, pyfreak wrote: > I accept this as normal now. I think, what I'll need to do if I'm > against stripping off the two character

Re: django python pi-charts/graphs

2010-06-02 Thread Euan Goddard
I would recommend using google charts. There are a couple of python implementations for this. I've used GChartWrapper with some success, but found it a little clunky in its implementation. Euan On Jun 2, 7:35 am, rahul jain wrote: > Hi Django, > > I would like to represent my db/model content in

Re: Get last object with certain value

2010-06-11 Thread Euan Goddard
Hi, I've done something similar to this using annotation. It is a bad nasty, but should work. Firstly annotate all the MyModel instances with the max value of the pk of the MyOtherModel: qs = MyModel.objects.annotate(last_pk=Max('myothermodel__pk')) Then filter these based on the myString: qs

Re: Running syncdb from an install script in django_project/install

2010-06-11 Thread Euan Goddard
This sounds like a path type issue and these sorts of things are a PITA to sort out. Have you tried setting the settings path a bit more explitly: os.environ["DJANGO_SETTINGS_MODULE"]="django_project.settings" I had some trouble with kind of thing in a project I was working on (https://launchpad.

Re: Using array type data in Django/ Postgresql

2010-06-11 Thread Euan Goddard
I'd just create a related model and use a many-to-many field. Alternatively you could write your own field, but this would restrict your application to postgres only. Euan On Jun 10, 1:03 pm, bjja wrote: > Hi > > Psycopg2 supports array types but I can not find any evident > information whether

Re: ordering integers with regroup

2010-06-11 Thread Euan Goddard
It should be easy enough to write your own tag providing you're expecting your input in the form . I've written a bit of code that should do this: import re LABEL_RE = re.compile(r'^(\w+) (\d+)$') def order_by_number(unordered_data): tokenized_data = [] for item in unordered_data:

Re: Multiple AJAX sends within a views.py-function

2010-06-11 Thread Euan Goddard
If you're worried about the data getting out of order use a counter in JS and always ensure that you only update the page when you get the correct (i.e. current) counter back. I think what you're talking about isn't possible in normal HTTP. I think you have a one request, one response situation.

Re: Reconnecting after a database restart

2011-01-10 Thread Euan Goddard
As far as I know Django maintains a persistent connection to the database server and restarting the server without restarting the client isn't possible. We never restart our live database server in production (we fail over to a secondary server so that the app is essentially only vulnerable for a f

Re: method of method

2011-01-25 Thread Euan Goddard
I agree with the previous poster - the title is misleading as the word "method" is incorrect in both places. It seems that the original poster is talking about denormalizing data. However, this is unnecessary as the ORM allows for this type of data to be retrieved any how, e.g. Car.objects.all().s

Announcing djeneralize

2011-01-25 Thread Euan Goddard
Hi, I've recently been working on an open source project to augment the inheritance of models in Django. This project, called "djeneralize" allows you to declare specializations on your models and then query the general case model and get back the specialized instances. A simple example of the mod

Re: Announcing djeneralize

2011-01-25 Thread Euan Goddard
write the package was just to augment Django's model inheritance which did almost everything we needed. Thanks again for the link. Euan On Jan 25, 2:26 pm, Tom Evans wrote: > On Tue, Jan 25, 2011 at 11:43 AM, Euan Goddard wrote: > > Hi, > > > I've recently bee

Re: Getting hold of an instance of a model from inside RelatedManager

2011-01-25 Thread Euan Goddard
can't you do self.model.main? On Jan 25, 3:34 pm, kmpm wrote: > I have some issues with getting hold of the instance of a Model to which a > RelatedManager got contributed to. > Is that at all possible and if so, how? > > From *my_method* below I can get hold of the model *RelatedStuff* by callin