Thursday 15 January 2015

How to show date_created in Django admin -


I have a model built in below Django 1.5:

  class number (Model model): phone_number = models.CharField ("phone number", max_length = 10, exclusive = true)   

I set the Django administrator as below:

  Django.contrib import admin from demo.models import messages, numbers, relationships, smsog class number admin (admin.modeladmin): search_fields = ['phone_number'] admin.site.register (number, number modern)   

I believe Django has the "date_created" column on its own. Adding to the database by type (because I know it changes the data entry from the creation time in the admin console). Is there any way to see those times / dates in the Admin console? The closest I'm going to do, but I do not want to make another column on my own (in the example of Jenato official tutorials on pub_date ) and if possible, is there a way to do this? And if so, how can someone show me? Thanks!

Digeng does not automatically add a date_created column if you want to track the date of creation You have to declare it in your model.

You may have the illusion that this happens because if you do not specify a sort order in the model or in the admin class for the model, it will default to the sorting by the primary key According to the orders made according to the examples will increase.

No comments:

Post a Comment