Code

Opened 6 years ago

Closed 6 years ago

#7265 closed (fixed)

Add timestamp output to runserver when "Validating models..."

Reported by: Valera Grishin Owned by: nobody
Component: Tools Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This is simple improvement to the Django development server available through "manage.py runserver" command. The goal is to add output of current time to the string "Validating models..."

So the proposition is to change this:

!#python
# django/core/management/commands/runserver.py:47

            print "Validating models..."

To this:

!#python
# django/core/management/commands/runserver.py

            print "[%s] Validating models..." % str(datetime.datetime.now())[11:19]

This will cause the output:

Validating models...

to to be similar to this:

[21:30:42] Validating models...

Obviously you need to import datetime at the top of file (not shown in the example above). Full patch is attached.

Attachments (1)

current_time_at_validating.patch (792 bytes) - added by Valera Grishin <valery.grishin@…> 6 years ago.
Patch for django/core/management/commands/runserver.py

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by Valera Grishin <valery.grishin@…>

Patch for django/core/management/commands/runserver.py

comment:1 follow-up: Changed 6 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

What problem does this solve that can't be solved in other ways?

comment:2 in reply to: ↑ 1 Changed 6 years ago by anonymous

Replying to ubernostrum:

What problem does this solve that can't be solved in other ways?

This let's you see whether development server has reloaded after certain file has been changed.

Development server monitors the source files for the changes and reloads if any file has changed (i.e. saved in the editor). Reason for change is that server don't reload always. This is not the bug of the development server but rather changing the file that isn't monitored for certain reason.

Now assume you've edited and saved few source files in a row. Than you switch to development server console to check whether it reloaded. The timestamp near "Validating models..." will tell you exactly whether server has reloaded right now or you just seeing some former reloads (assume here you didn't request any pages in between the saves and reloads).

I've tried to find the way to the timestamp without touching the Django source codes but didn't succeeded.

comment:3 Changed 6 years ago by anonymous

In your settings.py file, put

import datetime
print str(datatime.datetime.now())

The settings file is reloaded every time the server restarts, so this will print the current day and time whenever the dev server restarts.

comment:4 Changed 6 years ago by Valera Grishin

  • Resolution set to fixed
  • Status changed from new to closed

Thanks for the idea! Though it is better to put this output into the init.py instead of settings.py because the latter gets loaded more then once.
I'm closing the ticket.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.