Performance when retrieving data from related models

2013-03-15 Thread Taras_96
My web app hits the database up to 3k per page because it has to retrieve data from lots of related models. It has a fairly normalised database with a structure similar to: - one project has many contracts - one project has many tenders (a tender is put forward by a contractor) - one contract h

Re: Design by composition and persistance

2012-12-29 Thread Taras_96
> in your case: > > class Event(models.Model): > name = models.CharField(.) > description = models.CharField() > tw_start = models.DateTimeField() > tw_finish= models.DateTimeField() > timewindow = TimeWindowField(tw_start, tw_finish) > > and getDuration() is a me

Re: Design by composition and persistance

2012-12-29 Thread Taras_96
data consistency. However, it doesn't really make much sense to incur the cost of this (through joins) if the object that is being modelled is a value object. So does anyone have any experience with this problem/trade-off in the Django world? On Saturday, 29 December 2012 18:53:05 UTC+11,

Design by composition and persistance

2012-12-28 Thread Taras_96
Hi, I'm stuck on the best way of implementing design by composition in Django, and was wondering if anyone had any suggestions/pointers/past experiences. Say you're designing an event management program. Each event has a name, occurs in a suburb, and has a start time and end time. Say you want

Re: Returning JSON error when catching Django exception

2012-06-21 Thread Taras_96
ould be in a normal view. In that case: > > return HttpResponse(json_data, mimetype="application/json") > > > On Thu, Jun 21, 2012 at 6:54 AM, Taras_96 wrote: > >> Does anyone have opinions on the best way of having middleware catch >> exceptions, and instead

Returning JSON error when catching Django exception

2012-06-21 Thread Taras_96
Does anyone have opinions on the best way of having middleware catch exceptions, and instead of rendering the error into a HTML template, to return a JSON object? Currently I have the middleware below that catches exceptions, and if it can find an extra user error message, puts that onto the

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

2012-04-21 Thread Taras_96
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 worked, but was now throwing. I've removed the 'id' p