How to hide the "save and add another" button in admin page?

3,825 views
Skip to first unread message

RLF_UNIQUE

unread,
Jan 19, 2014, 1:38:32 AM1/19/14
to django...@googlegroups.com
I have been trying all day. What I am doing is trying to have a model for an "about" page, which I want to limit to 1 item. It doesn't really make sense to have multiple "abouts". I've done everything described here


but can't get it to work, it works if in the ctx update I set show_save_and_add_another to false, but then the "save and add another" button doesn't show up for any model.

Please help.

parnigot

unread,
Jan 19, 2014, 9:33:21 AM1/19/14
to django...@googlegroups.com
Il 19/01/14 02:38, RLF_UNIQUE ha scritto:
You should override in your ModelAdmin the method has_add_permissions (docs here).
When it returns False, all the add buttons in the admin will be disabled for that particular Model.

-- 
e.p.

RLF_UNIQUE

unread,
Jan 19, 2014, 5:34:53 PM1/19/14
to django...@googlegroups.com
Ah I see, give a user change permission but not add or remove? Then just use superaccount to make initial entry?

parnigot

unread,
Jan 20, 2014, 8:01:34 AM1/20/14
to django...@googlegroups.com
If your method ModelAdmin.has_add_permission() returns always False even a superuser can’t add the initial entry using the admin. But you can:

  • Add the initial entry using the command line.
  • Write a more complex has_add_permission method that checks if the request.user is a superuser or checks if  the initial entry already exists.

e.p.

Il giorno 19/gen/2014, alle ore 18:34, RLF_UNIQUE <rlfu...@gmail.com> ha scritto:

Ah I see, give a user change permission but not add or remove? Then just use superaccount to make initial entry?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f2b936f2-7107-4dad-bd3a-364cae68cb37%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

m1chael

unread,
Jan 20, 2014, 10:15:54 PM1/20/14
to django...@googlegroups.com
How about extending a template and issuing a CSS visibility ?
> https://groups.google.com/d/msgid/django-users/8154DDBF-5293-4355-84D6-FB49FF2FE040%40gmail.com.
Reply all
Reply to author
Forward
0 new messages