# Feature request: clear console on reload

**URL:** <https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837>\
**Category:** Django Internals\
**Created:** [February 14, 2025, 9:10am UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837 "2025-02-14T09:10:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![iTrooz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/itrooz/32/26915_2.png) [@iTrooz](https://forum.djangoproject.com/u/iTrooz)\
**Post date:** [February 14, 2025, 9:10am UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/1 "2025-02-14T09:10:26Z")

</div>

Hello !  
I’d like to add a feature to Django to automatically clear the console when hot-reloading.  
This could be implemented as a flag, for example by doing `python manage.py runserver --clear-on-reload`

I’m ready to submit a PR for this myself, at some point in the future.

What do you think about this feature ?

---

<div class="post-metadata">

**Author:** ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)\
**Post date:** [February 14, 2025, 11:21am UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/2 "2025-02-14T11:21:34Z")

</div>

I’m not sure. For the cases where I get lost in my console output, I’ll add a few newlines and that usually does the trick for me. Otherwise, I don’t really bother with clearing my scrollback.

I wonder if this would be more acceptable for django-extensions’ runserver\_plus? Or maybe you can find a way for people to experiment with this so they can be convinced this feature is a major benefit?

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [February 14, 2025, 3:57pm UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/3 "2025-02-14T15:57:05Z")

</div>

Just to be clear, “clearing the console" won’t mean actually removing the scrollback. It just means restarting rendering from the top of the screen. The way to achieve this is `print("\x1bc")`. Scroll

Personally, I’m not really a fan of the proposal.

First, I like the way the output stays pinned to the bottom of the window. Reloading pushing that to the top seems unnecessary, as it will require scanning back up the window to find the latest requests.

Second, it would presumably mean clearing after the `INFO <filename> changed, reloading.` log message, making it a little bit harder to debug issues with unexpected reloads.

But thanks for the suggestion @itrooz, it’s always good to see developer experience improvements being thought about. I think some colourization would be an easier way to improve the development server output.

---

<div class="post-metadata">

**Author:** ![iTrooz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/itrooz/32/26915_2.png) [@iTrooz](https://forum.djangoproject.com/u/iTrooz)\
**Post date:** [February 15, 2025, 3:24pm UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/4 "2025-02-15T15:24:31Z")

</div>

> [@adamchainz](#):
>
> Just to be clear, “clearing the console" won’t mean actually removing the scrollback. It just means restarting rendering from the top of the screen. The way to achieve this is `print("\x1bc")`. Scroll

Yeah I meant that sorry

> [@adamchainz](#):
>
> First, I like the way the output stays pinned to the bottom of the window. Reloading pushing that to the top seems unnecessary, as it will require scanning back up the window to find the latest requests.

The problem I encountered with this was while debugging an endpoint, Django was printing a long stacktrace. And I wanted to read the _latest_ stacktrace, and not the one before by mistake. So I ended up disabling auto-reload, and just `clear`-ing the console and re-running Django every time I modified my code, which was annoying

Alternatively, I suppose I could run Django through something like `nodemon` for auto-restarting the process (something like `npx nodemon --signal SIGKILL --ext py --exec "clear && python manage.py runserver"`) but I’d love an easier option to exist.

> [@adamchainz](#):
>
> Second, it would presumably mean clearing after the `INFO <filename> changed, reloading.` log message, making it a little bit harder to debug issues with unexpected reloads.

I think showing the “reloading” message after clearing the console should not be a problem

> [@CodenameTim](#):
>
> I wonder if this would be more acceptable for django-extensions’ runserver\_plus?

I never heard about django-extensions before today. Unfortunately, I don’t want to add a dependency on my code (you have to add the `django_extensions` to your INSTALLED\_APPS right ?) just for a QoL improvement in a dev environment

> [@CodenameTim](#):
>
> Or maybe you can find a way for people to experiment with this so they can be convinced this feature is a major benefit?

So creating and keeping up-to-date a fork of Django and seeing if people want to use it, for an added clear command ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 15, 2025, 4:11pm UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/5 "2025-02-15T16:11:03Z")

</div>

Welcome @iTrooz !

> [@iTrooz](#):
>
> And I wanted to read the _latest_ stacktrace, and not the one before by mistake.

I’m in the habit of going to the console window and holding down the return key to give me 10ish blank lines between tests.

> [@iTrooz](#):
>
> Unfortunately, I don’t want to add a dependency on my code (you have to add the `django_extensions` to your INSTALLED\_APPS right ?) just for a QoL improvement in a dev environment

Personally, I would find it extremely difficult to give up at this point. It’s an essential part of my development environment. (Yes, I know not everyone is a fan of it, but I am. And, depending upon what commands you use, it _could_ also be a vital part of your production environment as well.)  
But, in the minimal case, I don’t really consider it much different than DjangoDebugToolbar or any other dev-time usage package. It’s easily removed for production deployments.

> [@iTrooz](#):
>
> So creating and keeping up-to-date a fork of Django and seeing if people want to use it, for an added clear command ?

Doesn’t need to be a full Django fork. It could be a third-party package of a custom command, much in the same realm as `django-extensions`.

---

<div class="post-metadata">

**Author:** ![iTrooz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/itrooz/32/26915_2.png) [@iTrooz](https://forum.djangoproject.com/u/iTrooz)\
**Post date:** [February 17, 2025, 4:05pm UTC](https://forum.djangoproject.com/t/feature-request-clear-console-on-reload/38837/6 "2025-02-17T16:05:58Z")

</div>

> [@KenWhitesell](#):
>
> I’m in the habit of going to the console window and holding down the return key to give me 10ish blank lines between tests.

I agree that this helps, but I’m still anxious if I don’t clear the console

So, id I understand correctly, there is a lower barrier for merging on `django-extensions`. I will try my luck there then, thanks !
