Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django DateTimeField show Date and Time input in the same line in admin

Suppose I have a model with DateTimeField.

And for DateTimeField, currently admin input is:

enter image description here

Is it possible to customize it to enter image description here

like image 553
Pang Avatar asked Nov 18 '25 08:11

Pang


1 Answers

You can do that by overriding the admin css. You basically have to .vDateField, .vTimeField elements. Create a template admin/change_form.html in your templates folder. Add the following lines to that file

{% extends "admin/change_form.html" %}
{% block extrastyle %}
.vDateField, .vTimeField {
    display: block;
}
{% endblock %}

Django picks up this file, reads it and processes it before processing the original template file.

like image 103
Sarath Somana Avatar answered Nov 19 '25 23:11

Sarath Somana