On 17/12/2017 9:26 AM, Daniel Roseman wrote:
This is expected behaviour. You've set them to be populated automatically on 
create and update. So there's no need to be modifiable via the admin.

Of course!

However, if you want to see the fields you have to mention them among other fields you wish to display as indicated below and - based on Daniel's advice above - you might need to include ...

readonly_fields = ['timestamp', 'updated']

On 17/12/2017 8:18 AM, Mike Dewhirst wrote:
On 16/12/2017 10:06 PM, Mukul Agrawal wrote:
Hello, I am newbie to django. I was trying my hand on models. When i used the below code in models.py, "timestamp" and "updated" are not able visible on admin site. Is something wrong with the code?

It looks OK to me. Have you included them in your admin.py ...
        fieldsets = (
            ('RestaurantLocation', {
                'fields': (
                    'name',
                    'location',
                    'category',
                    'timestamp',
                    'updated',
                    ),
                }
            ),
        )



'''
from django.db import models

# Create your models here.
class RestaurantLocation(models.Model):
    name             = models.CharField(max_length=120)
    location         = models.CharField(max_length=120, null=True, blank=True)     category         = models.CharField(max_length=120, null=True, blank=True)     timestamp        = models.DateTimeField(auto_now=False,auto_now_add=True)     updated          = models.DateTimeField(auto_now=True, auto_now_add=False)
'''
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com <https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7589b965-420d-9df8-cf91-dab04a40c2ff%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to