Good question! :)

I don't know...like I said I hadn't thought it through! :)
I'll ponder it a bit...

maybe you'd have to tackle it in a different direction...Say something like
this:

you have a dropdown in your project model that's blankable/nullable and it
would essentially be a FK to other projects...

When you clicked save (or save and continue working) you would have a custom
save method that would go through and pull out all the information you
wanted about that other project and pull it in to the new project.

Does that make sense? Unfortunatly, it means you have to click a button to
load the inherited values...BUT this way you can make sure that the users
are selecting the right project to inherit from...

ALSO it would have to only work on the creation of an object...not the
changing of an object. (ie so you don't override the new values with the
inherited ones every time...)

OR you could have it check to see if those values are null, if they are null
put in the inherited values, else pass..

n

PS I'm just thinking of things off the top of my head! :)
On Wed, Sep 15, 2010 at 4:16 AM, pixelcowboy <pixelcowbo...@gmail.com>wrote:

> Im not sure Im getting this properly. In the example above, how would
> you know what the word "whatever", the query value, stands for? How
> could you keep it dynamic in that the values of that field is taken
> from whatever the actual parent object is? Thanks.
>
>
> On Sep 14, 2:34 pm, pixelcowboy <pixelcowbo...@gmail.com> wrote:
> > I'll try when I get home, but thanks again for your help!
> >
> > On Sep 14, 11:31 am, "nick.l...@gmail.com" <nick.l...@gmail.com>
> > wrote:
> >
> >
> >
> > > Hi again! :)
> >
> > > I haven't thought this idea through, and very well could be
> > > wildly inefficient! :)
> >
> > > Though in your admin.py when registering the admin model do something
> like
> > > this:
> >
> > > from myproject.myapp.models import MyModel, OtherModel
> >
> > > class MyModelAdmin(models.admin):
> > >     object_i_want = OtherModel.objects.get(field_i_care_about=whatever)
> > >     prepopulated_fields = { "field_i_care_about":
> > > (object_i_want.field_i_care_about)
> >
> > > admin.site.register(MyModel, MyModelAdmin)
> >
> > > On Tue, Sep 14, 2010 at 3:59 PM, pixelcowboy <pixelcowbo...@gmail.com
> >wrote:
> >
> > > > Hi, I want a project structure that is as follows:
> >
> > > > I have an application with project model that has a subproject, and
> > > > that subproject has other subproject,etc. What I want to get is that
> > > > the subproject gets the same attributes that the parent project, but
> > > > is also able to override their values in its own instance (but not in
> > > > the parent instance).
> >
> > > > My first idea is using something like a foreign key. This gives me
> > > > access to the parent values, but not the ability to override them.
> >
> > > > The second option is multi-table inheritance from the parent class.
> > > > This gives me the parents class attributes, but I again I dont get
> the
> > > > fields in the admin, so Im not able to override them (at least not in
> > > > the admin). Is there any way to this?
> >
> > > > The third option is to inherit an abstract class. The parent also
> > > > inherits from this class, so both have the fields I need. However, I
> > > > would like for the child class to inherit default values for this
> > > > fields from the parent class, but be free to override them. Is there
> > > > any way to pre-populate fields in the admin with the attribute values
> > > > from a parent or related files?
> >
> > > > Thanks for your help.
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@google groups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > Guadajuko! Vamos a correr!
> > >  -"Cool! we are going to run!"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Guadajuko! Vamos a correr!
 -"Cool! we are going to run!"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to