no plus-sign to add related object in admin

82 views
Skip to first unread message

K.C. Smith

unread,
Dec 29, 2011, 3:58:28 PM12/29/11
to Django users
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.

Furbee

unread,
Dec 29, 2011, 4:07:46 PM12/29/11
to django...@googlegroups.com
Just taking a stab in the dark, are the ones without the + sign editable in the Admin? If they are not editable, I would imagine Django would not show the + in the Admin.

Furbee


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


K.C. Smith

unread,
Dec 30, 2011, 10:43:24 AM12/30/11
to Django users
Thanks for your input. I think you're probably right about non-
editable objects. Unfortunately, that's not it in this case.

K.C.

Oleg Korsak

unread,
Dec 30, 2011, 11:32:29 AM12/30/11
to django...@googlegroups.com
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

2011/12/30 K.C. Smith <kevc...@gmail.com>:

K.C. Smith

unread,
Dec 30, 2011, 1:32:24 PM12/30/11
to Django users
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
>

K.C. Smith

unread,
Jan 5, 2012, 2:57:34 PM1/5/12
to Django users
I have written a small patch that will add this feature (i.e., the
ability to register a model in the admin and stop it from showing up
in the index). If your problem was the same as mine, then this can
get the plus signs where you want them without changing your preferred
admin view. See https://code.djangoproject.com/ticket/17498 for
details.

K.C.

Reply all
Reply to author
Forward
0 new messages