Re: Why not Single Table Inheritance?

2014-06-11 Thread Florian Apolloner
On Wednesday, June 11, 2014 2:16:06 AM UTC+2, Craig de Stigter wrote: > > I reserve judgment on whether STI should be included in core. It works > fine in a third-party app. Some better support for it in core would be > helpful, since currently I'm relying on some unsupported stuff that the >

Re: Why not Single Table Inheritance?

2014-06-10 Thread Craig de Stigter
Late reply I know but I see a lot of FUD in this thread and I want to try and clear it up. > in the general case, STI means you have to make almost all the fields in your model NULLable. You lose any semblance of having an actual database schema, and end up writing a whole lot of code to re-im

Re: Why not Single Table Inheritance?

2014-06-06 Thread Aymeric Augustin
On 6 juin 2014, at 09:42, Thomas Güttler wrote: > I think it is a "not invented here" syndrome: Ruby on Rails did it before. > That's > a reason to do it different. The reason is more simple. Rails was designed around MySQL, a database with a rather casual relationship to data integrity. It wi

Re: Why not Single Table Inheritance?

2014-06-06 Thread Shai Berger
Let me expand on Russell's expletives: On Friday 06 June 2014 09:42:15 Thomas Güttler wrote: > > I guess a lot of developers don't want to hear the next lines: > > I think it is a "not invented here" syndrome: Ruby on Rails did it before. > That's a reason to do it different. > This does deser

Re: Why not Single Table Inheritance?

2014-06-06 Thread Russell Keith-Magee
er methods to add the >> select_related calls and "interpret" the type field properly; so I don't >> see an >> immediate need for inclusion in core. >> >> Well, you don't need select_related calls at all, if you're actually >> storing thin

Re: Why not Single Table Inheritance?

2014-06-06 Thread Thomas Güttler
immediate need for inclusion in core. Well, you don't need select_related calls at all, if you're actually storing things in one table like "single-table inheritance" implies. I too was surprised to find Django doesn't do this, and was unable to find a good third-pa

Re: Why not Single Table Inheritance?

2014-05-25 Thread Craig de Stigter
ll, you don't need select_related calls at all, if you're actually storing things in one table like "single-table inheritance" implies. I too was surprised to find Django doesn't do this, and was unable to find a good third-party app that does it. So I wrote my own: htt

Re: Why not Single Table Inheritance?

2014-05-22 Thread Anssi Kääriäinen
On 05/22/2014 11:13 AM, Shai Berger wrote: Any thoughts on this idea? Instinctively -- isn't it possible to achieve the same things today by overriding __new__ ? My understanding is that achieving all the same things isn't possible. The problem is that inside __new__ it is impossible to know i

Re: Why not Single Table Inheritance?

2014-05-22 Thread Shai Berger
On Thursday 22 May 2014 11:05:24 Anssi Kääriäinen wrote: > I think it is time to add a new model classmethod from_db() to Django. > > The idea is to allow customization of object initialization when loading > from database. Instead of calling directly model.__init__ from the queryset > iterators,

Re: Why not Single Table Inheritance?

2014-05-22 Thread Anssi Kääriäinen
On Monday 12 May 2014 12:27:01 Thomas Güttler wrote: > >> Single Table Inheritance is used by ruby-on-rails and SQLAlchemy. > >> > >> Are there reasons why it is used in django? > >> > > > > Essentially, STI is a form of database denormalization.

Re: Why not Single Table Inheritance?

2014-05-16 Thread Carl Meyer
On 05/16/2014 04:46 AM, Shai Berger wrote: > On Monday 12 May 2014 12:27:01 Thomas Güttler wrote: >> Single Table Inheritance is used by ruby-on-rails and SQLAlchemy. >> >> Are there reasons why it is used in django? >> > > Essentially, STI is a form of databas

Re: Why not Single Table Inheritance?

2014-05-16 Thread Shai Berger
On Monday 12 May 2014 12:27:01 Thomas Güttler wrote: > Single Table Inheritance is used by ruby-on-rails and SQLAlchemy. > > Are there reasons why it is used in django? > Essentially, STI is a form of database denormalization. I think Django should not encourage this. > I woul

Re: Why not Single Table Inheritance?

2014-05-15 Thread Christian Schmitt
This is already merged. https://docs.djangoproject.com/en/1.6/topics/db/models/#multi-table-inheritance Am Montag, 12. Mai 2014 11:27:01 UTC+2 schrieb guettli: > > Single Table Inheritance is used by ruby-on-rails and SQLAlchemy. > > Are there reasons why it is used in django?

Re: Why not Single Table Inheritance?

2014-05-15 Thread Tom Evans
On Thu, May 15, 2014 at 4:11 PM, Christian Schmitt wrote: > This is already merged. > > https://docs.djangoproject.com/en/1.6/topics/db/models/#multi-table-inheritance > MTI is not STI, nor is it polymorphic. Cheers Tom -- You received this message because you are subscribed to the Google Gro

Why not Single Table Inheritance?

2014-05-12 Thread Thomas Güttler
Single Table Inheritance is used by ruby-on-rails and SQLAlchemy. Are there reasons why it is used in django? I would love to see a polymorphic inheritance solution in django. I know that there are third party apps which provide this, but something like this should be in the core. There was

Re: Single table inheritance - working implementation

2012-12-23 Thread Krzysztof Jurewicz
Dnia 2012-12-21, pią o godzinie 11:05 -0800, Anssi Kääriäinen pisze: > I went with a different approach than the patch for 1.5. At this stage > as minimal as possible change to get_default_columns() seemed like a > good idea. See commit a0155f35343afbfd9e98ab9aa4615f06780f697e in > stable/1.5.x. >

Re: Single table inheritance - working implementation

2012-12-21 Thread Anssi Kääriäinen
On 21 joulu, 16:39, Krzysztof Jurewicz wrote: > On 13.12.2012 15:54, Anssi K ri inen wrote: > > > Second, I have created a patch which should allow your work to > > continue working in master. See > >https://github.com/akaariai/django/commit/94c417d2a29a0f72b26019fc38e... > > - the idea is to chan

Re: Single table inheritance - working implementation

2012-12-21 Thread Krzysztof Jurewicz
On 13.12.2012 15:54, Anssi Kääriäinen wrote: Second, I have created a patch which should allow your work to continue working in master. See https://github.com/akaariai/django/commit/94c417d2a29a0f72b26019fc38ef400420097aa4 - the idea is to change get_fields_with_model() so that it doesn't return

Re: Single table inheritance - working implementation

2012-12-13 Thread Anssi Kääriäinen
Third, I think it is a good idea to add more abstraction between the ORM and the Model/Fields layer. So, in this way I do support the idea of using proxy models for single table inheritance. On the other hand it should not be surprising if in the future "different fields than parents"

Re: Single table inheritance - working implementation

2012-12-11 Thread Anssi Kääriäinen
nheritance hierarchy for Proxy models with > > automatic type recasting. I've written a fork of it with additional > > possibility of adding fields to subclasses, therefore achieving a single > > table inheritance implementation similar to Ruby on Rails' STI. > > Refr

Re: Single table inheritance - working implementation

2012-12-07 Thread Krzysztof Jurewicz
n a fork of it with additional possibility of adding fields to subclasses, therefore achieving a single table inheritance implementation similar to Ruby on Rails' STI. Refreshing this thread because it looks like my fork stopped working properly with recent Django master. I suspect that commi

Re: Single table inheritance - working implementation

2012-10-29 Thread Craig de Stigter
ecasting. I've written a fork of it with additional > possibility of adding fields to subclasses, therefore achieving a single > table inheritance implementation similar to Ruby on Rails' STI. This is > possible mostly thanks to metaclass magic and monkey patching. > > The for

Single table inheritance - working implementation

2012-10-29 Thread Krzysztof Jurewicz
sibility of adding fields to subclasses, therefore achieving a single table inheritance implementation similar to Ruby on Rails' STI. This is possible mostly thanks to metaclass magic and monkey patching. The fork's homepage is at https://github.com/KrzysiekJ/django-typed-models. N

Re: Single Table Inheritance

2011-03-30 Thread Alex Robbins
If you need to be able to filter and search across models, you could try haystack. http://docs.haystacksearch.org/dev/searchqueryset_api.html#filter I've setup a site with a real base class, done queries on that and then returned the child classes. It worked, but it felt pretty hacky all the way

Re: Single Table Inheritance

2011-03-30 Thread Forest Bond
e to write > Document.objects.all(). I'd then like to be able to iterate over this > enumerable and have each object cast to its proper class. > > This is something accomplished with single table inheritance in Rails; > why don't we have the equivalent in Django? > > I kno

Re: Single Table Inheritance

2011-03-29 Thread Johannes Dollinger
Am 29.03.2011 um 20:46 schrieb Shawn Milochik: > They can create a custom manager on the abstract class that would > return an iterable, perhaps using itertools.chain() of the querysets. > > It depends on what they expect to do with the output of this custom > manager, and they'd obviously lose

Re: Single Table Inheritance

2011-03-29 Thread Carl Meyer
On 03/29/2011 02:46 PM, Shawn Milochik wrote: > I'm not proposing a change to Django itself or suggesting that this > should be a standard practice. I do think that this is a fairly clean > solution for an individual to use to solve this problem if they have > it. > > They can create a custom ma

Re: Single Table Inheritance

2011-03-29 Thread Shawn Milochik
On Tue, Mar 29, 2011 at 2:21 PM, Carl Meyer wrote: > Hi Shawn, > > What you've outlined here is certainly possible (and yes, you'd need to > subclass the ModelBase metaclass). I haven't looked at the abstract > inheritance stuff recently, but I think there would be some alternative > ways for the

Re: Single Table Inheritance

2011-03-29 Thread Carl Meyer
Hi Shawn, On 03/29/2011 01:28 PM, Shawn Milochik wrote: > Hopefully someone on the core dev team can let me know if this is > possible in Django. If so, it will solve this problem. > I am not familiar with custom metaclass stuff done within models.Model. > > 1. Create a custom metaclass as descri

Re: Single Table Inheritance

2011-03-29 Thread Jeremy Dunck
On Tue, Mar 29, 2011 at 11:40 AM, Carl Meyer wrote: > On 03/29/2011 12:40 PM, Jeremy Dunck wrote: >> What about keeping abstract inheritance in this case, but allowing >> Document.objects.* to work by returning instances of the subclasses. >> Filtering, etc. would only work based on the Document b

Re: Single Table Inheritance

2011-03-29 Thread Shawn Milochik
Hopefully someone on the core dev team can let me know if this is possible in Django. If so, it will solve this problem. I am not familiar with custom metaclass stuff done within models.Model. 1. Create a custom metaclass as described in "Pro Python," page 124. 2. Add this metaclass to the abstra

Re: Single Table Inheritance

2011-03-29 Thread Jordan MacDonald
Cool. Well, maybe I can look into how abstract base classes are currently implemented and see if there's a way to generate query sets for all derived classes from the parent. Thanks for the insight! On Mar 29, 12:40 pm, Carl Meyer wrote: > On 03/29/2011 12:40 PM, Jeremy Dunck wrote: > > > What

Re: Single Table Inheritance

2011-03-29 Thread Carl Meyer
On 03/29/2011 12:40 PM, Jeremy Dunck wrote: > What about keeping abstract inheritance in this case, but allowing > Document.objects.* to work by returning instances of the subclasses. > Filtering, etc. would only work based on the Document base class. > > It would mean doing some unions, but would

Re: Single Table Inheritance

2011-03-29 Thread Jeremy Dunck
On Tue, Mar 29, 2011 at 11:11 AM, Carl Meyer wrote: > Hi Jordan, > > On 03/29/2011 11:40 AM, Jordan MacDonald wrote: >> I have three models, structured like so: >> >> Document >> -Presentation >> -Spreadsheet ... >> I'd like to be able to write >> Document.objects.all(). I'd then like to be able

Re: Single Table Inheritance

2011-03-29 Thread Carl Meyer
mes where I want to list/ > search across all documents, and I'd like to be able to write > Document.objects.all(). I'd then like to be able to iterate over this > enumerable and have each object cast to its proper class. > > This is something accomplished with single table inherit

Single Table Inheritance

2011-03-29 Thread Jordan MacDonald
is something accomplished with single table inheritance in Rails; why don't we have the equivalent in Django? I know I could just use the Document class and have a type field, but then I have to do all of the type checking legwork manually. I was hoping Django would handle normalizing/d