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...@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.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to