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

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

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
> > > What I have > = > > class MyFunModel(models.Model): > my_foo_field = > > What I am attempting to add > = > > class MyAnotherFunModel(MyFunModel): > my_another_foo_field = > > Such that the migration gives me *only* _myanotherfunmodel table with > fields "

Re: Model inheritance with constraints

2016-05-28 Thread Akhil Lawrence
Its already addressed. You can simply run ./manage.py makemigrations and ./manage.py migrate it will create migrations only for MyAnotherFunModel On Thursday, 26 May 2016 01:02:08 UTC+5:30, Arnab Banerji wrote: > > Hi all, > > I currently have a set of models associated with my Django app, w

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

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 September 2013 15:2

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

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
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 related_name for each model. Cheers, Tom Dne Wed, 12 Jun 2013 01:10:40 -0700 (PDT) Benjamin

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

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 ): >    

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
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. Carles. On 28 Oct, 01:39, Tom Eastman wrote:

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.

Re: Model inheritance and simple access

2010-06-08 Thread Jason Beaudoin
sounds like magic, though django usually handles magic well :) On Tue, Jun 8, 2010 at 7:18 PM, John M wrote: > I was hoping to avoid that type of code, but instead have put a field > in the linked parent to indicate what type the child is and then have > a method in the parent as a property whic

Re: Model inheritance and simple access

2010-06-08 Thread John M
I was hoping to avoid that type of code, but instead have put a field in the linked parent to indicate what type the child is and then have a method in the parent as a 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 cas

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: try:

Re: Model inheritance and simple access

2010-06-08 Thread John M
Hmm, that doesn't really get me what I want, it just caches the related child objects in one SQL query. What I want is a single interface and have django figure out what type of child object I have (like multiple inheritance but 'better'). So in my example: p = Parent1.objects.get(id=1) p.child.

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

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

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

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

Re: Model inheritance - filtering base model only

2009-11-23 Thread lfrodrigues
I guess this solution works but for +50 the performance should be terrible... Shouldn't django have some option for this? On 23 Nov, 04:53, Preston Holmes wrote: > Perhaps there is a more efficient way, but in my quick test, one can't > filter() a queryset based on __class__ of the model, bu

Re: Model inheritance - filtering base model only

2009-11-22 Thread Preston Holmes
Perhaps there is a more efficient way, but in my quick test, one can't filter() a queryset based on __class__ of the model, but seems one can manually filter it afterwords: qs = Player.objects.all() for i,obj in enumerate(qs): if obj.__class__ != Player: del(qs[i]) On Nov 22, 4:32 p

Re: Model inheritance problem, inherited instances

2009-07-22 Thread Peter Cicman
Hi Rodrigue, thats exactly what i tried as a first, but unfortunately something like this doesn't work. And seems there isn't any "standard" workaround for this. Solutions are: 1.) call raw sql for creating record in B table, 2.) copy all local_fields values from a to b, after this save works..

Re: Model inheritance problem, inherited instances

2009-07-21 Thread Rodrigue
If you look here http://docs.djangoproject.com/en/dev/topics/db/models/#id7 you'll see that multi-table inheritance is handled at the db level "via an automatically-created OneToOneField". This means that an instance of B has a foreign key to an instance of A. At the model level, there should be

Re: Model Inheritance

2009-07-09 Thread Randy Barlow
Javier Guerra wrote: > On Thu, Jul 9, 2009 at 5:52 PM, Randy Barlow wrote: >> sjtirtha declared: >>> class Media(Document): >>>link = >>>type = >>>class Meta: >>>abstract = True >>> >>> class Image(Media): >>> size = . >> You should know that this will generat

Re: Model Inheritance

2009-07-09 Thread Kalyan Lanka
As Randy Barlow said you cannot have the same column name in Document and Media. If you change the name, two tables Document and Image will be created with Media columns in Image and Document has its only Columns. Media refers to Document. Cheers, Kalyan Lanka On Thu, Jul 9, 2009 at 6:15 PM, sjt

Re: Model Inheritance

2009-07-09 Thread Javier Guerra
On Thu, Jul 9, 2009 at 5:52 PM, Randy Barlow wrote: > sjtirtha declared: >> class Media(Document): >>    link = >>    type = >>    class Meta: >>        abstract = True >> >> class Image(Media): >>     size = . > > You should know that this will generate three DB tables.  The media a

Re: Model Inheritance

2009-07-09 Thread Randy Barlow
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 sjtirtha declared: > Hi, > > I'm new in Django and now I'm already facing the issue with Model > Inheritance. > Here is my imagination, how the model should like > > class Document(models.Model): >name = ... >type = > > > class Medi

Re: Model Inheritance question

2009-06-25 Thread Randy Barlow
LeeRisq wrote: > If I am looking to use an abstract base class with multiple models, > which is assigned the primary key id? The child or the parent? Abstract classes don't get database tables at all, so only the child will have the key. --~--~-~--~~~---~--~~ You

Re: model inheritance and column ordering

2009-04-07 Thread rvr
Thanks for the reply. There's no real problem. I just want the audit columns to appear after the more important ones if I'm looking at the db. I guess it's a matter of readability. On Apr 8, 11:04 am, Malcolm Tredinnick wrote: > On Tue, 2009-04-07 at 19:30 -0700, rvr wrote: > > Is there a way to

Re: model inheritance and column ordering

2009-04-07 Thread Malcolm Tredinnick
On Tue, 2009-04-07 at 19:30 -0700, rvr wrote: > Is there a way to specify a field in an abstract base class, but have > the corresponding column appear last in the table's column list? > > class A(models.Model): > ts = models.DateTimeField(default=datetime.now()) > class Meta: > a

Re: Model inheritance vs. User.get_profile()

2009-03-18 Thread Johan
HaHa (After some reading) Silly me my way is the get_profile route :) On Mar 18, 4:58 pm, Johan wrote: > Hiya , > >   I don't know the get_profile route (Am going to read up on that > now :)). But here is an example of what I'm using : > >   class Student(models.Model): >     base = mod

Re: Model inheritance vs. User.get_profile()

2009-03-18 Thread Johan
Hiya , I don't know the get_profile route (Am going to read up on that now :)). But here is an example of what I'm using : class Student(models.Model): base = models.OneToOneField(User, primary_key=True) first_name = models.CharField(max_length=100) last_name = models.CharField(m

Re: Model inheritance vs. User.get_profile()

2009-03-18 Thread ntoll
Thanks for the information and link Malcolm. To cut a long story short, I'll just use get_profile(). On Mar 17, 11:32 pm, Malcolm Tredinnick wrote: > On Tue, 2009-03-17 at 09:49 -0700,ntollwrote: > > Guys, > > > Asking for advice here. > > > What is the best way to extend the User class in > > d

Re: Model inheritance vs. User.get_profile()

2009-03-18 Thread ntoll
Dougal, Thanks for the heads up... looks like I'l user get_profile if only for the the next guy who comes along... :-) Nicholas. On Mar 17, 11:01 pm, Dougal Matthews wrote: > get_profile is newer than model inheritance I believe. > Working with profile is how everybody seems to be doing it, so

Re: Model inheritance vs. User.get_profile()

2009-03-17 Thread Malcolm Tredinnick
On Tue, 2009-03-17 at 09:49 -0700, ntoll wrote: > Guys, > > Asking for advice here. > > What is the best way to extend the User class in > django.contrib.auth.models...? > > I could either inherit the class for my own model and add fields / > methods or use get_profile(). Now, whilst I realise

Re: Model inheritance vs. User.get_profile()

2009-03-17 Thread Dougal Matthews
get_profile is newer than model inheritance I believe. Working with profile is how everybody seems to be doing it, so follow the trend and it'll make every bodies lives easier ;) If you really want to read more about it, there is loads of chatter on the subject so to avoid reppetition; http://www.

Re: model inheritance without a new database table

2009-02-25 Thread Ryan Kelly
Thanks again for your feedback on this Malcolm, I've created the following ticket in Trac: Proxy models: subclass a model without creating a new table http://code.djangoproject.com/ticket/10356 Cheers, Ryan -- Ryan Kelly http://www.rfk.id.au | This message is digitally signed

Re: model inheritance without a new database table

2009-02-24 Thread Malcolm Tredinnick
On Wed, 2009-02-25 at 16:06 +1100, Ryan Kelly wrote: [...] > > The use-case for the pure-Python inheritance that has been floating > > around is the case when you want to, say, use a different User manager > > in your own views. You don't want to change the auth app's behaviour in, > > say, admin,

Re: model inheritance without a new database table

2009-02-24 Thread Ryan Kelly
> Oh, okay. Yeah, that's quite different. I'm not convinced that should go > into Django. Again, there's a consistency thing: we present the object / > class type that is asked for, not some transparently descended version. I think my explanation may have been a bit off... > The use-case for the

Re: model inheritance without a new database table

2009-02-24 Thread Malcolm Tredinnick
On Wed, 2009-02-25 at 15:12 +1100, Ryan Kelly wrote: > > > If I'm feeling inspired tomorrow, I might try to formulate similar logic > > > as a patch to the ModelBase metaclass, so that subclasses that don't add > > > any fields will get pure-python inheritance by default. > > > > That (changing t

Re: model inheritance without a new database table

2009-02-24 Thread Ryan Kelly
> > If I'm feeling inspired tomorrow, I might try to formulate similar logic > > as a patch to the ModelBase metaclass, so that subclasses that don't add > > any fields will get pure-python inheritance by default. > > That (changing the default behaviour) would be a bad idea. The > implicit prima

Re: model inheritance without a new database table

2009-02-24 Thread Malcolm Tredinnick
On Tue, 2009-02-24 at 22:38 +1100, Ryan Kelly wrote: > > > is there a way to have a model subclass avoid the creation of a > > > new database table,and just take its data straight out of the table for > > > its superclass? > > > > Right now, I suspect you would also have to manually set Meta.db

Re: model inheritance without a new database table

2009-02-24 Thread Ryan Kelly
> > is there a way to have a model subclass avoid the creation of a > > new database table,and just take its data straight out of the table for > > its superclass? > > Right now, I suspect you would also have to manually set Meta.db_table > and some things like that. However, I strongly suspect

Re: model inheritance without a new database table

2009-02-22 Thread Ryan Kelly
> There's a ticket open in Trac (my internet connection is terrible at the > moment, so I'm not going to hunt it out) that is to add an option to the > Meta class saying "this model is not to be managed by Django". Thanks Malcolm, I'll definitely take a look and see if I can help out on the ticket

Re: model inheritance without a new database table

2009-02-22 Thread Malcolm Tredinnick
On Mon, 2009-02-23 at 17:11 +1100, Malcolm Tredinnick wrote: [...] > There's a ticket open in Trac (my internet connection is terrible at the > moment, so I'm not going to hunt it out) that is to add an option to the > Meta class saying "this model is not to be managed by Django". > Primarily, tha

Re: model inheritance without a new database table

2009-02-22 Thread Malcolm Tredinnick
On Mon, 2009-02-23 at 16:54 +1100, Ryan Kelly wrote: > Hi All, > > > I'm currently working on an authentication backend that adds some > functionality to the standard one, and as part of this I want to modify > the behaviour of the User class. I've been subclassing auth.models.User > using st

Re: model inheritance with foreign key problem

2009-01-16 Thread Karen Tracey
On Fri, Jan 16, 2009 at 7:14 AM, Marco Minutoli wrote: > > I have these three models: > > class Address(models.Model): >name = models.CharField(max_length=100) >## many other fields ## > >class Meta: >ordering = ('name',) > >def __unicode__(self): >return self.name

Re: Model Inheritance with external apps

2008-12-16 Thread bruno desthuilliers
On 16 déc, 19:07, Lyubomir Petrov wrote: > I'm just starting a project that is using django-profile. There are > some fields like "country" that i want to remove. > As in django-profiles I use my own class that extends the base class > (BaseProfile), so i can add some common information fields. >

Re: Model Inheritance

2008-11-29 Thread Malcolm Tredinnick
On Sun, 2008-11-30 at 03:14 -0200, Felipe Sodré Silva wrote: > Hello folks. I have three models: [...] > I know that this is going to generate three different tables. > I want to know if is it possible to do: > > cars = Car.objects.all() > for c in cars: > ..print c.render() > > and get the e

Re: model inheritance - getting data from child objects

2008-11-14 Thread Enrico
Maybe this could help: http://www.djangosnippets.org/snippets/1187/ --~--~-~--~~~---~--~~ 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 unsubscri

Re: model inheritance - getting data from child objects

2008-11-08 Thread euglena
Use ContentType. Read about it in django documentation On Nov 8, 2:03 am, Alistair Marshall <[EMAIL PROTECTED]> wrote: > On Nov 7, 4:19 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > > > I don't know if it's clever or stupid, but this is what I have done in a > > similar situation: > > It appea

Re: model inheritance - getting data from child objects

2008-11-07 Thread Alistair Marshall
On Nov 7, 4:19 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > I don't know if it's clever or stupid, but this is what I have done in a > similar situation: > It appears to be a nice solution - it throws an error If I try to get_related() on a generic non-specialised place rather than just ret

Re: Model Inheritance - And Signals

2008-11-07 Thread Vitaly Babiy
Thanks Alex that worked great. Vitaly Babiy On Fri, Nov 7, 2008 at 12:19 PM, Alex Koshelev <[EMAIL PROTECTED]> wrote: > Try to connection handler without `sender` specified. And filter needed > models inside it. > > def my_handler(sender, **kwargs): > if not isinstance(sender, CustomModel):

Re: Model Inheritance - And Signals

2008-11-07 Thread Alex Koshelev
Try to connection handler without `sender` specified. And filter needed models inside it. def my_handler(sender, **kwargs): if not isinstance(sender, CustomModel): return signals.pre_save.connect(my_handler) On Fri, Nov 7, 2008 at 20:03, Vitaly Babiy <[EMAIL PROTECTED]> wrote: > if

Re: model inheritance - getting data from child objects

2008-11-07 Thread Gerard flanagan
Alistair Marshall wrote: > As I said, I have the function named the same in each child class but > I need to be able to access it from a list of all the Places. > > My current thinking is just a long list of try, except: statements > attempting to call the subclass from the Place model but this f

Re: model inheritance - getting data from child objects

2008-11-06 Thread Pawel Pilitowski
On 07/11/2008, at 3:01 AM, Alistair Marshall wrote: On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If all worker classes (cook, waiter, ...) are subclassed from Worker, > something like this should work: Worker.objects.filter(workplace=...) > Unfortunately the function that ea

Re: model inheritance - getting data from child objects

2008-11-06 Thread Alistair Marshall
On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If all worker classes (cook, waiter, ...) are subclassed from Worker, > something like this should work: Worker.objects.filter(workplace=...) > Unfortunately the function that each child will run is a bit more complicated than just l

Re: model inheritance - getting data from child objects

2008-11-06 Thread Thomas Guettler
I have never used model inheritance, but I read the documentation If all worker classes (cook, waiter, ...) are subclassed from Worker, something like this should work: Worker.objects.filter(workplace=...) (Given that workers only work for one workplace) HTH, Thomas Alistair Marshall sch

Re: Model inheritance question

2008-11-02 Thread felix
see also this: http://www.djangosnippets.org/snippets/1031/ for a tumblelog I have been actually fetching queries for each item type, concatenating them as lists, then sorting by date. that's much simpler since its usually mostly display. I mostly use model inheritance in situations where I need

Re: Model inheritance question

2008-11-02 Thread Ramiro Morales
On Sun, Nov 2, 2008 at 4:52 AM, void <[EMAIL PROTECTED]> wrote: > > Can someone point to the correct way to do this? > > Suppose i'm working in a tumblelog, it's basically , 4 o 5 tipes of > "post item" that share some cmmon information. > > So the first approach i would go is: > > cllass Post(mod

Re: Model Inheritance and save

2008-10-13 Thread sanrioyt
Hi, Sorry for not checking it further. I think the problem was on my end. It actually does work. Thanks, sanrio On Oct 13, 10:26 am, meppum <[EMAIL PROTECTED]> wrote: > What do you mean "this did not work"? did you get an error? or did the > logic in model a's save not run? > > On Oct 13, 11:1

Re: Model Inheritance and save

2008-10-13 Thread sanrioyt
Can anyone help? Thanks, sanrio On Oct 10, 11:30 am, [EMAIL PROTECTED] wrote: > Hi, > > How does the save work, if you have a base abstract class that has > save, and the parent class has save? > > For example: > > Model A: >save(self): > super(A, self).save() > >class Meta: >

Re: Model Inheritance in new-forms admin

2008-07-18 Thread Russell Keith-Magee
On Fri, Jul 18, 2008 at 7:41 PM, cschand <[EMAIL PROTECTED]> wrote: > > Hi Russ >The problem is not solved in the ticket No - that's because it's a bug report. When the bug is fixed, the ticket will be closed. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You r

Re: Model Inheritance in new-forms admin

2008-07-18 Thread cschand
Hi Russ The problem is not solved in the ticket Satheesh On Jul 18, 4:13 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Fri, Jul 18, 2008 at 7:00 PM, cschand <[EMAIL PROTECTED]> wrote: > > > When I tried model inheritance in new-forms admin, I faced some > > problems > ... > > Wha

Re: Model Inheritance in new-forms admin

2008-07-18 Thread Andre Meyer
hi i had (and still have) the same problem . really hope this gets fixed (be)for(e) 1.0; patches seem to be available, so it can't be long... ;-)

Re: Model Inheritance in new-forms admin

2008-07-18 Thread Russell Keith-Magee
On Fri, Jul 18, 2008 at 7:00 PM, cschand <[EMAIL PROTECTED]> wrote: > > When I tried model inheritance in new-forms admin, I faced some > problems ... > What is wrong with me? You haven't checked the tickets: http://code.djangoproject.com/ticket/6755 Yours, Russ Magee %-) --~--~-~--~---

Re: Model inheritance problem in admin

2008-07-14 Thread David
Thanks, Malcolm. It was great to see inheritance in the first place, and we'll just wait for newforms-admin to use an admin interface to it. On Jul 14, 5:51 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-07-14 at 14:46 -0700, David wrote: > > When I save objects from the admin p

Re: Model inheritance problem in admin

2008-07-14 Thread Malcolm Tredinnick
On Mon, 2008-07-14 at 14:46 -0700, David wrote: > When I save objects from the admin pages, I get COPIES of what I'm > saving. When I save them through the API, I don't get the duplicates. > I'd like to know if I'm doing something wrong or misunderstanding > something. You're assuming that model

Re: model inheritance and admin (qs-rf & nf-a)

2008-06-21 Thread felix
regarding Model Inheritance and the admin I've checked out the newforms-admin branch now. Its wonderful! Lots of great solutions. As of the other day its only a few revisions away from the trunk. (the trunk is being merged into newforms-admin) with Model inheritance the pointer field (to the

Re: model inheritance and admin (qs-rf & nf-a)

2008-06-19 Thread felix
I second that. I've just spent the day quite happily refactoring my app to use nifty model inheritance ... and the admin doesn't work. whoops. I think this should be stated in the docs for sure. On Jun 2, 4:44 pm, ekellner <[EMAIL PROTECTED]> wrote: > Is newforms-admin any closer to being m

Re: Model inheritance and primary keys

2008-06-03 Thread ekellner
On Tue, Jun 3, 2008 at 2:49 PM, Etienne Robillard <[EMAIL PROTECTED]> wrote: > I agree with you, and think this should be better expressed. Perhaps without > words which refers to abstract C++ concepts like pointers, and using a > vocabulary > more adapted to Python. At least this would be more

Re: Model inheritance and primary keys

2008-06-03 Thread Etienne Robillard
On Tue, 3 Jun 2008 12:33:25 +0200 ekellner <[EMAIL PROTECTED]> wrote: > > As I was looking at model inheritance with admin recently, I came > across this issue: > http://code.djangoproject.com/ticket/6755 > > I'm thinking now that the underlying issue that I'm seeing, and what > the patch in 67

Re: model inheritance and admin (qs-rf & nf-a)

2008-06-02 Thread ekellner
> Have you done any experimentation to see how far off working it is in the > newforms-admin branch...and whether it's any easier to fix there? I believe > the plan is to implement this support exclusively in newforms-admin and not > worry about getting it to work on the old admin. (Someone chan

Re: model inheritance and admin (qs-rf & nf-a)

2008-06-02 Thread Karen Tracey
On Mon, Jun 2, 2008 at 8:19 AM, Elizabeth Kellner <[EMAIL PROTECTED]> wrote: > On 28 Mai, 14:15, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > > Model inheritance is not supported by the admin: > > > > http://code.djangoproject.com/ticket/6755 > > > > There's a patch on that ticket, but I have no id

Re: model inheritance and admin (qs-rf & nf-a)

2008-06-02 Thread Elizabeth Kellner
On 28 Mai, 14:15, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > Model inheritance is not supported by the admin: > > http://code.djangoproject.com/ticket/6755 > > There's a patch on that ticket, but I have no idea if it works, solves the > complete problem, etc.  (If it were as easy as that patch, I

Re: model inheritance and admin (qs-rf & nf-a)

2008-05-28 Thread Andre Meyer
hi Karen thanks a lot, will check out the patch On Wed, May 28, 2008 at 2:15 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Wed, May 28, 2008 at 7:27 AM, Andre Meyer <[EMAIL PROTECTED]> > wrote: > >> hi all >> >> working with the newforms-admin branch i tried to build a model using >> model i

Re: model inheritance and admin (qs-rf & nf-a)

2008-05-28 Thread Karen Tracey
On Wed, May 28, 2008 at 7:27 AM, Andre Meyer <[EMAIL PROTECTED]> wrote: > hi all > > working with the newforms-admin branch i tried to build a model using model > inheritance: e.g. Task is a subclass of Item, fine. but in the admin > interface (this is probably true for old and newforms versions)

  1   2   >