Friday, December 30, 2011

Re: no plus-sign to add related object in admin

Hi, Oleg. I've discovered the issue (for my case, anyway). It goes
beyond the field definition.

The issue is that the FK fields which have no plus sign also have no
independent admin pages. Instead, they are administered underneath
another object as inlines. I have code in "admin.py" that is
analogous to this:

<code>
class kidsInline(admin.TabularInline) :
model = kids
extra = 5

class parentsAdmin(admin.ModelAdmin) :
inlines = [kidsInline]
save_on_top = True

admin.site.register(parents, parentsAdmin)
</code>

Then, it's the model "kids" that I have a FK field to in another
object, and it is that FK field that has no plus sign. It makes sense
that it has no plus sign, as it has no registered, stand-alone page
for adding a new object of that type ("kids").

So, this really just changes my question. I still want users to add
and edit the child object from the parent objects' admin page --
except in the case when they need to add a new one of those child
objects from the third object's add/edit page. ... A simple way to
accomplish this might be if I could register the "kids" object with
the admin site (with say "admin.site.register(kids) "), but have it
NOT appear on the main "Site administration" page. I've been pouring
over the documentation and cannot see any way to do this.
"ModelAdmin" has so many options, though, that I'm still searching for
some sort of work-around.

K.C.

On Dec 30, 11:32 am, Oleg Korsak <kamikaze.is.waiting....@gmail.com>
wrote:
> Hi. Could you paste full field definition in your case? I have same
> problem and looks like I know when it doesn't have plus sign
>
> >> On Thu, Dec 29, 2011 at 12:58 PM, K.C. Smith <kevchr...@gmail.com> wrote:
> >> > I've got a project where when I pull up the admin page to add an
> >> > object (an object that has several foreign keys), some of the FK
> >> > fields show the little green plus-sign links to add a new related
> >> > object for that field and other FK fields do not.
>
> >> > In the past, I've seen the plus-sign link to add a new related object
> >> > on all of the FK fields.  Why would it not show up?
>
> >> > I'm using Django 1.2.5.
>
> >> > K.C.
>

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

No comments:

Post a Comment