Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:31:21+00:00 2026-06-10T21:31:21+00:00

I use the following get_readonly_fields method to not allow editing of objects in django’s

  • 0

I use the following get_readonly_fields method to not allow editing of objects in django’s admin interface:

def get_readonly_fields(self, request, obj=None):
    if obj == None or request.user.is_superuser:
        return self.readonly_fields

    # marks all fields as readonly otherwise
    fields = [f.name for f in self.model._meta.fields]
    return fields

This works perfectly, but the save and save and continue editing still show up. They won’t do anything since all fields are read-only.

Hence my question: Is there a way to hide these save buttons dependent on whether all fields are read-only or not? How could I implement this?

EDIT1:

I’m aware on how to override the admin/submit_line.html template, but what I would like to do instead, is to set the show_save, show_save_as_new to False if I only have read-only fields. How can I change these variable values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:31:22+00:00Added an answer on June 10, 2026 at 9:31 pm

    In django/contrib/admin there is a file called submit_line.html which renders the buttons. To override them, in your templates directory, create a folder called admin, and in admin/submit_line.html you would modify it the way you want (based on certain rules). Please note that modifying it this way would affect every admin object-view page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of objects, and i use following code to get in
I have the following Form defined class MyForm(ModelForm): def __init__(self, readOnly=False, *args, **kwargs): super(MyForm,self).__init__(*args,**kwrds)
I use the following to get, for instance, the header of the current page;
I can use the following to get the contents of a folder with no
I use the following script for get the values from HTML Table.If I use
If I use the following selector I get no results $(.itemSearchModule .cmsItemList[rel='myRelValue']) for the
I'm trying to use the following code to get all trace data for the
I use the following jquery statements but i get error in this function onGetDataSuccess(result)
I use the following javascript function, function get_check_value(formId,checkboxId,TxtboxId) { alert(formId); var c_value = ;
When I use the following PHP code: $id = $_GET['page']; $page = include ($id.'.php');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.