Re: Model inheritance with optional self reference

2021-03-16 Thread wongX Ndeso
Just facing the same problem with you bro, and i ended up with proxy model and using django-treebeard for the data hierarchy... On Thu, 11 Mar 2021 at 17.47 Kunal Solanke wrote: > Btw parts should be a m2m field ig. > > On Thu, Mar 11, 2021, 16:14 Kunal Solanke > wrote: > >> That's too hard of

Re: Model inheritance with optional self reference

2021-03-11 Thread Kunal Solanke
Btw parts should be a m2m field ig. On Thu, Mar 11, 2021, 16:14 Kunal Solanke wrote: > That's too hard of a problem statement for me,ig more experienced people > will be able to answer it more properly. But if its 99.99% I'd go with > whatever you have right now, rather than creating bunch or pr

Re: Model inheritance with optional self reference

2021-03-11 Thread Kunal Solanke
That's too hard of a problem statement for me,ig more experienced people will be able to answer it more properly. But if its 99.99% I'd go with whatever you have right now, rather than creating bunch or proxy models. On Thu, Mar 11, 2021, 16:06 Mateusz Wroblewski wrote: > Hi All, > > does anybod

Model inheritance with optional self reference

2021-03-11 Thread Mateusz Wroblewski
Hi All, does anybody have experience with the following data model and could advise which Django tools fit it best? Background: I have two types of Components (Core and Complex) that share many attributes and methods, but also have their own, specific data fields and methods. What complicates

Re: Model Inheritance across apps

2016-09-29 Thread Mike Dewhirst
On 30/09/2016 10:33 AM, Malik Rumi wrote: Assume two models, class Parent(models.Model): and Child(Parent): Assume they are both in the same Project Can Child be in a different app than Parent? In most cases the answer seems to be yes. True. You only need to import Parent. But it might be be

Model Inheritance across apps

2016-09-29 Thread Malik Rumi
Assume two models, class Parent(models.Model): and Child(Parent): Assume they are both in the same Project Can Child be in a different app than Parent? In most cases the answer seems to be yes. Each app has many other models to which Parent and Child, respectively, are closely tied - which is

Queries regarding Custom Managers with model inheritance.

2016-06-09 Thread Dheerendra Rathor
I was going through https://docs.djangoproject.com/en/1.9/topics/db/managers/#custom-managers-and-model-inheritance regarding custom managers and I decided to do some tests. Here are my models: from django.db import models class CustomManager(models.Manager): use_for_related_fields

Re: Model inheritance with constraints

2016-06-01 Thread James Schneider
On Wed, Jun 1, 2016 at 12:45 PM, Arnab Banerji wrote: > Nevermind my last comment on this thread, when I refactored my existing > model into an abstract base class with overrides, and then ran > "makemigrations", Django said "no changed detected", so it is merely > treated as a code refactor and

Re: Model inheritance with constraints

2016-06-01 Thread Arnab Banerji
Nevermind my last comment on this thread, when I refactored my existing model into an abstract base class with overrides, and then ran "makemigrations", Django said "no changed detected", so it is merely treated as a code refactor and not a database related change. Thanks AB -- You received t

Re: Model inheritance with constraints

2016-06-01 Thread Arnab Banerji
Hi Akhil - my issue was how to avoid the new OneToOne relationships, which James addressed on this post. Hi James - thanks a bunch for your help, much appreciated. While I like the WYSIWYG nature of this solution, I am not sure if the creation of the abstract base class will cause the data alre

Re: Model inheritance with constraints

2016-05-29 Thread James Schneider
*only* _myanotherfunmodel table with > fields "my_foo_field" and "my_another_foo_field", *without* touching any > data in the _myfunmodel table. > > None of the options in > https://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance > seem to addre

Re: Model inheritance with constraints

2016-05-28 Thread Akhil Lawrence
FunModel(MyFunModel): > my_another_foo_field = > > Such that the migration gives me *only* _myanotherfunmodel table with > fields "my_foo_field" and "my_another_foo_field", *without* touching any > data in the _myfunmodel table. > > None of the options i

Model inheritance with constraints

2016-05-25 Thread Arnab Banerji
ct.com/en/dev/topics/db/models/#model-inheritance seem to address this case, or maybe I am missing something? Thanks, AB -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it,

Re: proxy model inheritance generates a migration file in a third party app

2016-01-29 Thread Iliana Toneva
Hi Markus, Thank you very much, that solved the issue. Many thanks, Iliana On Thursday, 28 January 2016 17:31:36 UTC-7, Markus Holtermann wrote: > > Hello Iliana, > > this is due to the definition of app_label = 'actstream' on your proxy > model. This tells Django that this model should belo

Re: proxy model inheritance generates a migration file in a third party app

2016-01-28 Thread Markus Holtermann
Hello Iliana, this is due to the definition of app_label = 'actstream' on your proxy model. This tells Django that this model should belong to another app. Hence the migrations involving that model are added to the actstream app's migrations. /Markus On Friday, January 29, 2016 at 10:14:24 A

proxy model inheritance generates a migration file in a third party app

2016-01-28 Thread Iliana Toneva
Hello, I am using a third party app actstream (https://github.com/justquick/django-activity-stream) and am creating a proxy for one of the original actstream models : # myapp/models.py from actstream.models import Action # Subclass Actio

Re: Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-17 Thread guettli
> Sample Use-case- >>>> >>>> When the system is first deployed, a restaurant instance is created. >>>> Later, the restaurant adds a bar to increase revenue, and we now want to >>>> create a Bar model instance for the parent Place for the restaurant

Re: Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-13 Thread Simon Charette
restaurant instance is created. >>> Later, the restaurant adds a bar to increase revenue, and we now want to >>> create a Bar model instance for the parent Place for the restaurant. I >>> would propose the following interface for doing so: >>> >>>

Re: Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-13 Thread guettli
hour=True) >> >> However, if you attempt to create an instance in this manner now, you >> receive a DatabaseIntegrityError, saying that a Place object with that id >> already exists. >> >> }}} >> >> How to get this solved? >> >>

Re: Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-12 Thread Mario Gudelj
rant.objects.get(name__iexact="Bob's Place").parent > barInstance = Bar(parent=parentPlace, happy_hour=True) > > However, if you attempt to create an instance in this manner now, you > receive a DatabaseIntegrityError, saying that a Place object with that id > already

Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-12 Thread guettli
ur=True) However, if you attempt to create an instance in this manner now, you receive a DatabaseIntegrityError, saying that a Place object with that id already exists. }}} How to get this solved? There are work arounds: http://stackoverflow.com/questions/4064808/django-model-inheritance-create

Re: OneToOne field versus model inheritance

2015-01-22 Thread Collin Anderson
Hi, Django doesn't really provide a way to create a subclass from an already existing object in the admin. It's actually pretty hard to do even in the code. So for that reason I'd recommend the non subclass with the OneToOneField. Actually, if I were doing it, this is what I would do: class U

OneToOne field versus model inheritance

2015-01-20 Thread Paul Royik
I have three models: Person, Client, Member Person is a base model, Client and Member are profiles for Person. class Person(AbstractBaseUser, PermissionsMixin): email = models.EmailField( verbose_name=_('email address'), max_length=255, unique=True, ) class Client

Re: Possible Model Inheritance Issue? Error: [Model_Name] instance needs to have a primary key value before a many-to-many relationship can be used

2014-05-11 Thread João Pedro Melo
I know this is a VERY VERY old thread but oh my god I love you, I was having the same problem for the same reason and would have never imaged that was why (though it makes sense). Took me a long time to finally find this thread. On Thursday, January 22, 2009 1:38:57 AM UTC-2, Keyton Weissinger

True Model Inheritance

2014-04-11 Thread Thomas Güttler
I know that there are several model inheritance extensions available: https://www.djangopackages.com/grids/g/model-inheritance/ But it is hard for me to decide which one to take. The most common solutions seem to be: django-model-utils django-polymorphic My use case is simple: This

Re: db performance with model inheritance vs. alternatives

2013-12-04 Thread Matthias Dahl
Hello @all, just to be clear and honest upfront: I've just posted this question on http://stackoverflow.com/questions/20373194/db-performance-with-model-inheritance-vs-alternatives as well. I hope this is okay and doesn't upset anyone. Thanks again. So long, Matthias -- Dipl

db performance with model inheritance vs. alternatives

2013-12-04 Thread Matthias Dahl
jumps to mind is model inheritance for the plugins. But since it is unforeseeable how many plugins an installation will have and how many a specific model instance will have attached to it or what kind of plugins (since the plugin system is heterogenous), performance is a great concern of mine. Each

Re: model inheritance

2013-10-02 Thread Roberto López López
Is there maybe a way to set the cmsplugin_news.News.Meta.abstract option to True? In order to prevent accessing the parent model to fetch the inherited data. On 10/02/2013 03:45 PM, Leonardo Giordani wrote: > Are you sure your DB has been synced after putting the > ForeignKey(News) in your Depa

Re: model inheritance

2013-10-02 Thread Roberto López López
Hi Leonardo, thanks for your answer. Yes, it has been synced. The model itself is a little bit bigger, as you can notice from the code https://dpaste.de/c3Rg I am using as well the News model from https://github.com/wildfish/cmsplugin_news/blob/master/cmsplugin_news/models.py Regards, Roberto

Re: model inheritance

2013-10-02 Thread Leonardo Giordani
Are you sure your DB has been synced after putting the ForeignKey(News) in your Department model? Can you post somewhere the following models: News, OldNews, Department? Regards, Leo Leonardo Giordani Author of The Digital Cat My profile on About.me

model inheritance

2013-10-02 Thread Roberto López López
Hi, I am extending a 3rd party model in my application, using multi-table inheritance. I can create an instance and modify it, but when I try to list the created objects at http://localhost:8000/en/admin/news/news/ , I am getting a nice exception: Traceback: File "/home/roberto/.virt

Re: Model inheritance problem

2013-09-17 Thread George Lund
Ah okay, well I've never used that, I thought you were implying this could be a general Django question. Maybe neo4django doesn't support model inheritance -- I took a look at their site briefly and couldn't see anything about it. Sorry not to be more help... On Tuesday, 17 Se

Re: Model inheritance problem

2013-09-17 Thread Antonio Mignolli
Hmm, no, it does not work even without indexed=True, my mistake. So the "issue" remains. Il giorno martedì 17 settembre 2013 16:17:04 UTC+2, Antonio Mignolli ha scritto: > > Thanks, George, but as I said in the beginning, I'm using neo4django, > which surely has StringProperty, otherwise I woul

Re: Model inheritance problem

2013-09-17 Thread Antonio Mignolli
Thanks, George, but as I said in the beginning, I'm using neo4django, which surely has StringProperty, otherwise I would have an AttributeError on StringProperty, which I don't have. I should have written: from neo4django.db import models and ... name = models.StringProperty(indexed=True)

Re: Model inheritance problem

2013-09-17 Thread George Lund
> class MyBaseModel(models.NodeModel): >name=StringProperty() >class Meta: >abstract = True > > In Django you would need CharField or similar. StringProperty is a Google App Engine thing? Cf http://stackoverflow.com/questions/6132695/django-module-object-has-no-attribute-stringp

Model inheritance problem

2013-09-15 Thread Antonio Mignolli
Hi, I posted something similar also to italian Django-it group. I'm using neo4django, but I want to understand things in a more generic way. My case: class MyBaseModel(models.NodeModel): name=StringProperty() class Meta: abstract = True NodeModel it's a graph Node, like a record i

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
Hi Tom, On Wednesday, June 12, 2013 10:25:24 AM UTC+2, Tomáš Ehrlich wrote: > > Hi Benjamin, > you can create explicit OneToOne field with parent_link=True > > https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.OneToOneField.parent_link > > > Then you can set different r

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Tomas Ehrlich
) Benjamin Wohlwend napsal(a): > Hi, > > I have a bit of a problem with inherited reverse relations and django model > inheritance. Consider these models: > > > class Content(models.Model): > display = models.BooleanField() > > > class Link(Content): > u

Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Benjamin Wohlwend
Hi, I have a bit of a problem with inherited reverse relations and django model inheritance. Consider these models: class Content(models.Model): display = models.BooleanField() class Link(Content): url = models.URLField() class Teaser(Content): text = models.TextField

Re: Multiple model inheritance

2013-01-06 Thread nkryptic
yes, yes, no and yes. Abstract models should inherit form models.Model. Abstract models should always have a Meta class with abstract=True. The order matters when it comes to shared functionality. Here's how I would code those models you had: class Taggable(models.Model): tag = models.Ch

Re: Multiple model inheritance

2013-01-05 Thread Peter of the Norse
I’m not sure that’s possible. Even abstract Models do magic in the background. Specifically there's the _meta class attribute that gets inherited. If you were to try it, only one of the _metas would be included. On Dec 31, 2012, at 6:12 AM, Mattias Linnap wrote: > Hi all, > > I would like to d

Multiple model inheritance

2012-12-31 Thread Mattias Linnap
Hi all, I would like to define multiple abstract base models with small set of fields each. The "real" models inherit from multiple mixins to add the fields. For example: class Taggable(?): tag = models.CharField() class Visible(?): visible = models.BooleanField() class SomeFullModel(?, T

django-typed-models - sane single-table model inheritance

2012-02-19 Thread Craig de Stigter
In May last year I posted this topic<https://groups.google.com/d/topic/django-developers/1LA98LjNz-g/discussion>on django-developers. We wanted a way to do proxy-model inheritance, while preserving the type of each object when it goes in and out of the database. Unable to find anythin

Re: Model Inheritance Downcasting

2011-11-16 Thread Torsten Bronger
Hallöchen! Bastian Kuberek writes: > [...] > > What I need is to be able to query the Widget class and get back > subclasses based on their type: > widgets = Widget.objects.all() print widgets > [ 5>,] We do this very reliably with http://djangosnippets.org/snippets/2091/ but I fin

Re: Model Inheritance Downcasting

2011-11-16 Thread Tom Evans
On Wed, Nov 16, 2011 at 4:43 PM, Bastian Kuberek wrote: > Hi, > I have looked a lot and have not yet figured out how to accomplish this. > Let me show with an example what I am trying to accomplish. > > http://code.google.com/p/django-polymorphic-models/ Cheers Tom -- You received this messa

Model Inheritance Downcasting

2011-11-16 Thread Bastian Kuberek
Hi, I have looked a lot and have not yet figured out how to accomplish this. Let me show with an example what I am trying to accomplish. class WidgetType(models.Model): """WidgetType categorizes the type of Widget""" name = models.CharField(max_length=255) slug = models.SlugField(m

Re: Model Inheritance and ModelForms

2011-10-29 Thread Alex
Tom, Thanks for the quick reply! However, when I tried that I got an error saying that inventoryitem "is an invalid keyword argument for this function". I fixed this by manually specifying the OneToOneField relationship with the parent class as inventoryItem and setting parent_link=True. With that

Re: Model Inheritance and ModelForms

2011-10-28 Thread Tom Evans
On Fri, Oct 28, 2011 at 7:50 AM, Alex wrote: > I've been scouring Google and the Django documentation and I can't > figure out how to do this. I'm working on an inventory management > system for my shop. My inventory models.py similar to the following: > >    class ItemType( models.Model ): >    

Model Inheritance and ModelForms

2011-10-28 Thread Alex
I've been scouring Google and the Django documentation and I can't figure out how to do this. I'm working on an inventory management system for my shop. My inventory models.py similar to the following: class ItemType( models.Model ): def __unicode__( self ): return "blah bl

Model Inheritance and methods

2011-08-20 Thread CrabbyPete
I have the following models: class Deal(models.Model): """ Deal is a deal for Interest. There should only be one deal for each Interest pair """ interest = models.ForeignKey( Interest ) max_sell = models.IntegerField(default = 1) def terms(self): retur

Re: What are the advantages of Model inheritance?

2011-06-24 Thread bruno desthuilliers
On Jun 23, 11:40 pm, Micky Hulse wrote: > On Thu, Jun 23, 2011 at 2:17 PM, bruno desthuilliers > > wrote: > > FWIW, I have been using model inheritance - abstract and concrete - in > > half a dozen projects, with about 30 model subclasses in one of them, > > and it Jus

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Matthew Gardner
Jun 23, 2011 at 5:54 PM, Rich Jones wrote: > Even ignoring the select_related then - the fact is that > > user.post_set works and user.betterpost_set won't work, seemingly as > the result of using model inheritance. > > Perhaps I could get all of the posts (post and betterpos

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Rich Jones
Even ignoring the select_related then - the fact is that user.post_set works and user.betterpost_set won't work, seemingly as the result of using model inheritance. Perhaps I could get all of the posts (post and betterposts) and then filter by time? Does that make sense / is there a way

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Micky Hulse
On Thu, Jun 23, 2011 at 2:17 PM, bruno desthuilliers wrote: > FWIW, I have been using model inheritance - abstract and concrete - in > half a dozen projects, with about 30 model subclasses in one of them, > and it JustWorks(tm). That sounds pretty sweet! :D I would love to see some exa

Re: What are the advantages of Model inheritance?

2011-06-23 Thread bruno desthuilliers
On Jun 23, 8:24 pm, Rich Jones wrote: > Other than the convenience of writing them, I can't seem to find any > advantages of using model inheritance. Really ??? > Please allow me to explain the trouble I am having with an example. > Suppose, > > class Post(mod

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Cal Leeming [Simplicity Media Ltd]
s if I'm wrong though, as I have never encountered a need to > do this before, and just going off vague memory. > > Cal > > On 23/06/2011 19:24, Rich Jones wrote:Other than the convenience of > writing them, I can't seem to find any advantages of using model > inheritan

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Rich Jones
onvenience of writing > them, I can't seem to find any advantages of using model inheritance. Please > allow me to explain the trouble I am having with an example. Suppose, class > Post(models.Model): title = models.CharField(max_length=200) user_owner_id = > models.ForeignK

Re: What are the advantages of Model inheritance?

2011-06-23 Thread Cal Leeming [Simplicity Media Ltd]
Cal On 23/06/2011 19:24, Rich Jones wrote: Other than the convenience of writing them, I can't seem to find any advantages of using model inheritance. Please allow me to explain the trouble I am having with an example. Suppose, class Post(models.Model): title = m

What are the advantages of Model inheritance?

2011-06-23 Thread Rich Jones
Other than the convenience of writing them, I can't seem to find any advantages of using model inheritance. Please allow me to explain the trouble I am having with an example. Suppose, class Post(models.Model): title = models.CharField(max_length=200) user_owner_id = models.Forei

Re: Abstract Model Inheritance and Custom Managers?

2011-01-13 Thread Marc Aymerich
On Thu, Jan 13, 2011 at 9:10 PM, ringemup wrote: > If a manager is defined on an abstract model, do non-abstract child > models inherit the manager? http://docs.djangoproject.com/en/dev/topics/db/managers/#custom-managers-and-model-inheritance -- Marc -- You received this message becau

Abstract Model Inheritance and Custom Managers?

2011-01-13 Thread ringemup
If a manager is defined on an abstract model, do non-abstract child models inherit the manager? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, s

Re: problems with model inheritance if base class is not abstract

2010-11-21 Thread Marco Ferragina
Mmm yes it seems you are right. But I think this is a bit confusing thinking about object oriented programming, it is not? Then the only way to avoid this seems to be use an abstract base class or use some not so clean way to simulate this behavior. On 21 Nov, 01:36, Ramiro Morales wrote: > On

Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Joseph (Driftwood Cove Designs)
Ramiro - you made my day. Somehow I missed this little tid bit in the docs - what a super handy feature!! thank you. On Nov 20, 4:36 pm, Ramiro Morales wrote: > On Sat, Nov 20, 2010 at 7:59 AM, marco.ferrag...@gmail.com > > > > wrote: > > Hi all! I'm new to django and I'm experimenting with mod

Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Ramiro Morales
On Sat, Nov 20, 2010 at 7:59 AM, marco.ferrag...@gmail.com wrote: > Hi all! I'm new to django and I'm experimenting with models but I have > some trouble. I've minimized my problem to this code: > > class TestBase(models.Model): >    base = models.CharField(max_length=255) > > from django.contrib

Re: problems with model inheritance if base class is not abstract

2010-11-20 Thread Michael Sprayberry
--- On Sat, 11/20/10, marco.ferrag...@gmail.com wrote: From: marco.ferrag...@gmail.com Subject: problems with model inheritance if base class is not abstract To: "Django users" Date: Saturday, November 20, 2010, 5:59 AM Hi all! I'm new to django and I'm experimenti

problems with model inheritance if base class is not abstract

2010-11-20 Thread marco.ferrag...@gmail.com
Hi all! I'm new to django and I'm experimenting with models but I have some trouble. I've minimized my problem to this code: class TestBase(models.Model): base = models.CharField(max_length=255) from django.contrib import admin class TestA(TestBase): testb = models.CharField(max_length=25

Re: Model Inheritance.

2010-10-29 Thread Miguel Araujo
Hi Tom, You might want to have a look at inheritanceCastModel from django-model-utils by Carl Meyer http://github.com/carljm/django-model-utils Best regards, Miguel Araujo 2010/10/29 David De La Harpe Golden > On 29/10/10 00:04, Tom Eastman wrote: > > That's correct, but I want to take a 'Pla

Re: Model Inheritance.

2010-10-29 Thread David De La Harpe Golden
On 29/10/10 00:04, Tom Eastman wrote: That's correct, but I want to take a 'Place' object, that doesn't have a 'restaurant', and turn it *in to* a 'Restaurant' by adding the corresponding row to the Restaurant table. So you have a place. p = Place(name="3rd Circle of Hell") p.save() This sh

Re: Model Inheritance.

2010-10-28 Thread Tom Eastman
On 29/10/10 11:06, Carles Barrobés wrote: Your "place" object will contain an attribute called "restaurant" to access the object as an instance of the subclass. If this place object is an instance of another place subclass, accessing the restaurant attribute will raise a DoesNotExist error. Car

Re: Model Inheritance.

2010-10-28 Thread Carles Barrobés
, Tom Eastman wrote: > I'm working with model inheritance, and I need to convert my objects > into instances of its subclass.  Is there an easy way to do this? > > Looking at the example in: > > >http://docs.djangoproject.com/en/1.2/topics/db/models/#multi-table-in... &g

Model Inheritance.

2010-10-27 Thread Tom Eastman
I'm working with model inheritance, and I need to convert my objects into instances of its subclass. Is there an easy way to do this? Looking at the example in: http://docs.djangoproject.com/en/1.2/topics/db/models/#multi-table-inheritance I have a whole bunch of 'Place' o

Re: Bug in model inheritance?

2010-09-28 Thread phill
Alec, Thanks.. yeah, your fix forces the fields to pk=True, which doesn't redundantly serialize the field with it's custom name in my case. If for some reason you wanted to ensure that the field was serialized using it's custom field name though.. there doesn't appear to be a way to do that. I'm p

Re: Bug in model inheritance?

2010-09-28 Thread Alec Shaner
As to whether it's a bug or not I have no idea, though it seems so. If you use: entity = models.OneToOneField(Entity, parent_link=True, primary_key=True) it will create the primary key in both Kid and Adult tables, which sounds like what you want? On Tue, Sep 28, 2010 at 1:06 PM, phill wro

Bug in model inheritance?

2010-09-28 Thread phill
This looks quite a bit like a bug, but we may be off the reservation in terms of how we're using the product. (Disclaimer: I'm relatively new to Django, and extremely new to the codebase that I ran into this on). We've got a form of schema-inheritance going on in this project in order to accomplis

Re: Multi-table + Abstract Model Inheritance

2010-09-18 Thread ringemup
Well, on the surface this works. I'm sure if anything unexpected happens I'll be back. On Sep 17, 8:34 am, ringemup wrote: > Sure, it's easy enough to find out if it works in a general sense -- > but I'm also concerned about running into subtle bugs down the road, > and having to restructure my

Re: Multi-table + Abstract Model Inheritance

2010-09-17 Thread ringemup
Sure, it's easy enough to find out if it works in a general sense -- but I'm also concerned about running into subtle bugs down the road, and having to restructure my entire database as a result. On Sep 17, 4:15 am, bruno desthuilliers wrote: > On 16 sep, 22:11, ringemup wrote: > > > Is it pos

Re: Multi-table + Abstract Model Inheritance

2010-09-17 Thread bruno desthuilliers
On 16 sep, 22:11, ringemup wrote: > Is it possible for a model to inherit from an abstract model, which in > turn inherits from a non-abstract model? I don't thinks so, but I may be wrong. Now nothing prevents you from trying by yourself, it shouldn't take long to find out !-) -- You received t

Multi-table + Abstract Model Inheritance

2010-09-16 Thread ringemup
Is it possible for a model to inherit from an abstract model, which in turn inherits from a non-abstract model? Here's an example. In this case, the reason for using multi-table inheritance rather than an explicit one-to-one relation would be that the office addresses would be editable via office

Re: model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 3:15 PM, Roald de Vries wrote: On Aug 5, 2010, at 3:00 PM, Emily Rodgers wrote: On Aug 5, 1:50 pm, Roald de Vries wrote: Dear all, I have the following error, and don't know what it means: Error: One or more models did not validate: update.personupdate: 'address'

Re: model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 3:00 PM, Emily Rodgers wrote: On Aug 5, 1:50 pm, Roald de Vries wrote: Dear all, I have the following error, and don't know what it means: Error: One or more models did not validate: update.personupdate: 'address' has a relation with model Address, which has

Re: model inheritance, abtract=True

2010-08-05 Thread Emily Rodgers
On Aug 5, 1:50 pm, Roald de Vries wrote: > Dear all, > > I have the following error, and don't know what it means: > >      Error: One or more models did not validate: >      update.personupdate: 'address' has a relation with model Address,   > which has either not been installed or is abstract.

model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
Dear all, I have the following error, and don't know what it means: Error: One or more models did not validate: update.personupdate: 'address' has a relation with model Address, which has either not been installed or is abstract. I did a pretty big refactoring, but I think the proble

Re: Model inheritance and simple access

2010-06-08 Thread Jason Beaudoin
property which returns the correct child > type.  Works for now, would be nice if the framework kept track of it, > but it's a rare case. > > J > > On Jun 8, 12:41 pm, Dan Harris wrote: >> Not sure if this will work as I don't usually do much with model >&

Re: Model inheritance and simple access

2010-06-08 Thread John M
rare case. J On Jun 8, 12:41 pm, Dan Harris wrote: > Not sure if this will work as I don't usually do much with model > inheritance but according to docs > at:http://docs.djangoproject.com/en/dev/topics/db/models/#id7 > this might work (not pretty, but somewhat minimal co

Re: Model inheritance and simple access

2010-06-08 Thread Dan Harris
Not sure if this will work as I don't usually do much with model inheritance but according to docs at: http://docs.djangoproject.com/en/dev/topics/db/models/#id7 this might work (not pretty, but somewhat minimal code)... p = Parent1.objects.get(id=1) try: p.childa.basemthod() except:

Re: Model inheritance and simple access

2010-06-08 Thread John M
> On Tue, Jun 8, 2010 at 8:05 PM, John M wrote: > > I've gotten model inheritance working just fine, but was hoping > > someone could confirm the best way to access the model. > > > When I have a Base model which has a ForeignKey to a parent table, and > > that

Model inheritance and simple access

2010-06-08 Thread John M
I've gotten model inheritance working just fine, but was hoping someone could confirm the best way to access the model. When I have a Base model which has a ForeignKey to a parent table, and that base model has inherited models after it, how can I refer to only one name when referencin

Re: Model inheritance foreign key user

2010-04-04 Thread Thierry Chich
You are right but it would not change his problem. If 2 or more classes inherit from a class with a foreignkey or a manytomany, there will be a conflict in the related name Le 4 avr. 2010 à 14:11, Daniel Roseman a écrit : On Apr 3, 10:37 pm, Fredrik wrote: What I want is to "automat

Re: Model inheritance foreign key user

2010-04-04 Thread Daniel Roseman
On Apr 3, 10:37 pm, Fredrik wrote: > What I want is to "automatic" add an owner to every object.. > > Is there another way to accomplish the same? > > Fredrik > Do you need the PersistentModel field to exist in a separate table? It sounds to me as if that would be better off as an abstract model.

Re: Model inheritance foreign key user

2010-04-03 Thread Thierry Chich
Le 3 avr. 2010 à 23:37, Fredrik a écrit : What I want is to "automatic" add an owner to every object.. Is there another way to accomplish the same? I see. I have had a similar problem. I have tried a similar solution with exactly the same effect. I could have add manualy a foreignkey

Re: Model inheritance foreign key user

2010-04-03 Thread Fredrik
What I want is to "automatic" add an owner to every object.. Is there another way to accomplish the same? Fredrik On Apr 3, 10:48 pm, Thierry Chich wrote: > I think that if you want make inheritance it is because you want to   > have others subclasses. But then, your related name will be same

Re: Model inheritance foreign key user

2010-04-03 Thread Thierry Chich
I think that if you want make inheritance it is because you want to have others subclasses. But then, your related name will be same for all the subclasses. There is no solution with the stable version. In the dev version, it is possible to add the origin class name in the related_name. It is

Model inheritance foreign key user

2010-04-03 Thread Fredrik
Hi, I want to use it like this: """ class PersistentModel(models.Model): deleted = models.BooleanField(default = False) date_created = models.DateTimeField(default=datetime.now) date_edited = models.DateTimeField(default=datetime.now) owner = models.ForeignKey(User) class Contacts

Strange behaviour with select_related and model inheritance

2010-03-19 Thread Mark L.
Hello, Here is an extremely simple scenario: class Base(models.Model): f1 = models.CharField(max_length=64) class A(Base): f2 = models.CharField(max_length=64) class B(models.Model): f3 = models.CharField(max_length=64) b = models.OneToOneField('A', null=False, related_name="b_o

Re: Model Inheritance - best practice for templates?

2010-02-24 Thread fgasperino
mis-clicked, continuing: @register.filter def A_get_B(instance):     if isinstance(instance, B):         return instance.b     try:         return instance.b     except B.DoesNotExist:         return None and lastly, the template: {% with a|A_get_B as b %} {% if b %} .. work with b {% endif

Model Inheritance - best practice for templates?

2010-02-24 Thread fgasperino
All, Currently I'm working with the following 2 models: class A (models.Model): ... class B (A): somefield = ... I have a generic views with querysets defined as: url(r"A/view/(?P\d+)/$", "django.views.generic.list_detail.object_detail", dict(queryset = A.objects.all(), template_name =

Re: Model inheritance

2010-01-13 Thread Tomasz Zieliński
On 12 Sty, 20:52, a b wrote: > Hi, > > I have three models: > Product > SimpleProduct that extends Product > GroupProduct that extends Product and have ManyToMany relation with > SimpleProduct > > The reason to use the base Product model is so I can use paging. > Is it possible to make a query tha

Model inheritance

2010-01-12 Thread a b
Hi, I have three models: Product SimpleProduct that extends Product GroupProduct that extends Product and have ManyToMany relation with SimpleProduct The reason to use the base Product model is so I can use paging. Is it possible to make a query that gives a list of GroupProducts and SimpleProduc

Re: Model inheritance - filtering base model only

2009-11-23 Thread esatterwh...@wi.rr.com
a simple solution would be to put pass the contentype id and object id around in your url scheme domain.com/ct_id-object_id/ from there you can get the content type, which will be able to tell you the model, type, and give you the object. type = ContentType.objects.get(pk=ct_id) model =

Re: Model inheritance - filtering base model only

2009-11-23 Thread Doug Blank
On Mon, Nov 23, 2009 at 9:09 AM, lfrodrigues wrote: > I guess this solution works but for +50 the performance should be > terrible... > > Shouldn't django have some option for this? Could you set a field's value which is true for one, and false for the other? Otherwise, could you just have tw

  1   2   3   4   >