xemexpress
xemexpress

Reputation: 262

Django Admin change page: How can I put the save button set on the left, and delete button on the right?

Currently, I have the default setting.

enter image description here

How can I switch the positions of the save button sets and delete button while not affecting the mobile css layout (which I like to remain as itself)? What is the best way doing it?

Thank you!

Upvotes: 2

Views: 1137

Answers (2)

Dfranc3373
Dfranc3373

Reputation: 2177

Flip back to Save Button on the Right for Django 4.2.x+

For anyone looking to do the opposite of this (since Django updated the sides of Delete and Save by default in 4.2.x+) you can do the following:

Update templates/admin/base_site.html and add these lines:

    .submit-row{
        flex-direction: row-reverse;
    }
    .submit-row a.deletelink {
        margin-left: unset !important;
        margin-right: auto;
    }

This will flip set the Delete back on the Left and the Save on the right again

Screenshot in 4.2.2 after adding this CSS

Upvotes: 3

xemexpress
xemexpress

Reputation: 262

In templates/admin/base_site.html,

{% extends "admin/base_site.html" %}
{% load static %}

{% block extrahead %}
    <link rel="stylesheet" href="{% static 'css/admin/base.css' %}">
{% endblock %}

In static/css/admin/base.css,

.submit-row p.deletelink-box {
    float: right;
}

.submit-row [type=submit] {
    float: left !important;
}

.submit-row [name=_save] {
    margin-left: 0;
}

Then we will have enter image description here

Upvotes: 2

Related Questions